1 package tim.prune.data;
3 import tim.prune.I18nManager;
6 * Class to represent a field of a data point
10 private String _labelKey = null;
11 private String _customLabel = null;
12 private boolean _builtin = false;
14 public static final Field LATITUDE = new Field("fieldname.latitude", true);
15 public static final Field LONGITUDE = new Field("fieldname.longitude", true);
16 public static final Field ALTITUDE = new Field("fieldname.altitude", true);
17 public static final Field TIMESTAMP = new Field("fieldname.timestamp", true);
18 public static final Field WAYPT_NAME = new Field("fieldname.waypointname", true);
19 public static final Field WAYPT_TYPE = new Field("fieldname.waypointtype", true);
20 public static final Field DESCRIPTION = new Field("fieldname.description", true);
21 public static final Field NEW_SEGMENT = new Field("fieldname.newsegment", true);
23 public static final Field SPEED = new Field("fieldname.speed", true);
24 public static final Field VERTICAL_SPEED = new Field("fieldname.verticalspeed", true);
25 public static final Field MEDIA_FILENAME = new Field("fieldname.mediafilename", true);
27 // TODO: Ability to load media (from text) and save (to text)
29 /** List of all the available fields */
30 private static final Field[] ALL_AVAILABLE_FIELDS = {
31 LATITUDE, LONGITUDE, ALTITUDE, TIMESTAMP, WAYPT_NAME, WAYPT_TYPE, DESCRIPTION, NEW_SEGMENT,
32 SPEED, VERTICAL_SPEED,
33 new Field(I18nManager.getText("fieldname.custom"))
38 * @param inLabelKey Key for label texts
39 * @param inBuiltin true for built-in types, false for custom
41 private Field(String inLabelKey, boolean inBuiltin)
44 _labelKey = inLabelKey;
49 _customLabel = inLabelKey;
56 * Public constructor for custom fields
57 * @param inLabel label to use for display
59 public Field(String inLabel)
65 * @return the name of the field
67 public String getName()
69 if (_labelKey != null)
70 return I18nManager.getText(_labelKey);
75 * Change the name of the (non built-in) field
76 * @param inName new name
78 public void setName(String inName)
80 if (!isBuiltIn()) _customLabel = inName;
84 * @return true if this is a built-in field
86 public boolean isBuiltIn()
92 * Checks if the two fields are equal
93 * @param inOther other Field object
94 * @return true if Fields identical
96 public boolean equals(Field inOther)
98 return (isBuiltIn() == inOther.isBuiltIn() && getName().equals(inOther.getName()));
102 * Get the field for the given field name
103 * @param inFieldName name of field to look for
104 * @return Field if found, or null otherwise
106 public static Field getField(String inFieldName)
108 for (int i=0; i<ALL_AVAILABLE_FIELDS.length; i++)
110 Field field = ALL_AVAILABLE_FIELDS[i];
111 if (field.getName().equals(inFieldName)) {
120 * @return array of field names
122 public static String[] getFieldNames()
124 String[] names = new String[ALL_AVAILABLE_FIELDS.length];
125 for (int i=0; i<ALL_AVAILABLE_FIELDS.length; i++) {
126 names[i] = ALL_AVAILABLE_FIELDS[i].getName();