]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/data/Field.java
Version 8, September 2009
[GpsPrune.git] / tim / prune / data / Field.java
index 118fae3bab9d161c2ee8989a6bfbe261d5576018..5d0adc4563d25fd5465465226958eb59ebded0ca 100644 (file)
@@ -21,9 +21,11 @@ public class Field
        public static final Field WAYPT_TYPE = new Field("fieldname.waypointtype", FieldType.NONE);
        public static final Field NEW_SEGMENT = new Field("fieldname.newsegment", FieldType.BOOL);
 
-       public static final Field[] ALL_AVAILABLE_FIELDS = {
-                       LATITUDE, LONGITUDE, ALTITUDE, TIMESTAMP, WAYPT_NAME, WAYPT_TYPE, NEW_SEGMENT,
-                       new Field("fieldname.custom", FieldType.NONE)
+       // TODO: Field for photo filename, ability to load (from text) and save (to text)
+
+       private static final Field[] ALL_AVAILABLE_FIELDS = {
+               LATITUDE, LONGITUDE, ALTITUDE, TIMESTAMP, WAYPT_NAME, WAYPT_TYPE, NEW_SEGMENT,
+               new Field("fieldname.custom", FieldType.NONE)
        };
 
        /**
@@ -78,6 +80,14 @@ public class Field
                return _builtin;
        }
 
+       /**
+        * @return field type
+        */
+       public FieldType getType()
+       {
+               return _type;
+       }
+
        /**
         * Checks if the two fields are equal
         * @param inOther other Field object
@@ -87,4 +97,33 @@ public class Field
        {
                return (isBuiltIn() == inOther.isBuiltIn() && getName().equals(inOther.getName()));
        }
+
+       /**
+        * Get the field for the given field name
+        * @param inFieldName name of field to look for
+        * @return Field if found, or null otherwise
+        */
+       public static Field getField(String inFieldName)
+       {
+               for (int i=0; i<ALL_AVAILABLE_FIELDS.length; i++) {
+                       Field field = ALL_AVAILABLE_FIELDS[i];
+                       if (field.getName().equals(inFieldName)) {
+                               return field;
+                       }
+               }
+               // not found
+               return null;
+       }
+
+       /**
+        * @return array of field names
+        */
+       public static String[] getFieldNames()
+       {
+               String[] names = new String[ALL_AVAILABLE_FIELDS.length];
+               for (int i=0; i<ALL_AVAILABLE_FIELDS.length; i++) {
+                       names[i] = ALL_AVAILABLE_FIELDS[i].getName();
+               }
+               return names;
+       }
 }