From e26501e0ffb17453b2ccae22ab17cc9fca8f89b8 Mon Sep 17 00:00:00 2001
From: Brian Carrier <carrier@sleuthkit.org>
Date: Mon, 23 Sep 2013 16:51:05 -0400
Subject: [PATCH] Updated VolumeSystem.getType to return ENUM instead of long

---
 .../src/org/sleuthkit/datamodel/TskData.java  | 37 ++++++++++++++-----
 .../org/sleuthkit/datamodel/VolumeSystem.java |  5 ++-
 2 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/bindings/java/src/org/sleuthkit/datamodel/TskData.java b/bindings/java/src/org/sleuthkit/datamodel/TskData.java
index dcf279e91..971e3de06 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/TskData.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/TskData.java
@@ -499,19 +499,30 @@ public String getName() {
 	 * Volume System type
 	 */
     public enum TSK_VS_TYPE_ENUM {
-        TSK_VS_TYPE_DETECT(0x0000),    ///< Use autodetection methods
-        TSK_VS_TYPE_DOS(0x0001),       ///< DOS Partition table
-        TSK_VS_TYPE_BSD(0x0002),       ///< BSD Partition table
-        TSK_VS_TYPE_SUN(0x0004),       ///< Sun VTOC
-        TSK_VS_TYPE_MAC(0x0008),       ///< Mac partition table
-        TSK_VS_TYPE_GPT(0x0010),       ///< GPT partition table
-        TSK_VS_TYPE_DBFILLER(0x00F0),  ///< fake partition table type for loaddb (for images that do not have a volume system)
-        TSK_VS_TYPE_UNSUPP(0xFFFF);    ///< Unsupported
+        TSK_VS_TYPE_DETECT(0x0000, "Auto Detect"),    ///< Use autodetection methods
+        TSK_VS_TYPE_DOS(0x0001, "DOS"),       ///< DOS Partition table
+        TSK_VS_TYPE_BSD(0x0002, "BSD"),       ///< BSD Partition table
+        TSK_VS_TYPE_SUN(0x0004, "SUN VTOC"),       ///< Sun VTOC
+        TSK_VS_TYPE_MAC(0x0008, "Mac"),       ///< Mac partition table
+        TSK_VS_TYPE_GPT(0x0010, "GPT"),       ///< GPT partition table
+        TSK_VS_TYPE_DBFILLER(0x00F0, "Fake"),  ///< fake partition table type for loaddb (for images that do not have a volume system)
+        TSK_VS_TYPE_UNSUPP(0xFFFF, "Unsupported");    ///< Unsupported
         
         private long vsType;
-        private TSK_VS_TYPE_ENUM(long type){
+		private String name;
+        private TSK_VS_TYPE_ENUM(long type, String name){
             this.vsType = type;
+			this.name = name;
         }
+		
+		public static TSK_VS_TYPE_ENUM valueOf(long vsType) {
+			for (TSK_VS_TYPE_ENUM type : TSK_VS_TYPE_ENUM.values()) {
+				if (type.getVsType() == vsType) {
+					return type;
+				}
+			}
+			throw new IllegalArgumentException("No TSK_VS_TYPE_ENUM of value: " + vsType);
+		}
         
 		
 		/**
@@ -521,6 +532,14 @@ private TSK_VS_TYPE_ENUM(long type){
         public long getVsType() {
             return vsType;
         }
+		
+		/**
+		 * Get the name of the volume system type.
+		 * @return 
+		 */
+		public String getName() {
+			return name;
+		}
     };
 	
 	
diff --git a/bindings/java/src/org/sleuthkit/datamodel/VolumeSystem.java b/bindings/java/src/org/sleuthkit/datamodel/VolumeSystem.java
index 8265bc3d3..e6f8023d7 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/VolumeSystem.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/VolumeSystem.java
@@ -20,6 +20,7 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import org.sleuthkit.datamodel.TskData.TSK_VS_TYPE_ENUM;
 
 /**
  * Represents a volume system. Populated based on data in database.
@@ -66,8 +67,8 @@ public long getSize() {
 	 *
 	 * @return type
 	 */
-	public long getType() {
-		return type;
+	public TSK_VS_TYPE_ENUM getType() {
+		return TskData.TSK_VS_TYPE_ENUM.valueOf(type);
 	}
 
 	/**
-- 
GitLab