X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fdata%2FField.java;fp=tim%2Fprune%2Fdata%2FField.java;h=118fae3bab9d161c2ee8989a6bfbe261d5576018;hb=312fec956e43f5d0a38617da5d0add9c62563e2c;hp=0000000000000000000000000000000000000000;hpb=db1c1602b89209f4c92e8bd12ad38cd243fb27c7;p=GpsPrune.git diff --git a/tim/prune/data/Field.java b/tim/prune/data/Field.java new file mode 100644 index 0000000..118fae3 --- /dev/null +++ b/tim/prune/data/Field.java @@ -0,0 +1,90 @@ +package tim.prune.data; + +import tim.prune.I18nManager; + +/** + * Class to represent a field of a data point + * including its type + */ +public class Field +{ + private String _labelKey = null; + private String _customLabel = null; + private FieldType _type = null; + private boolean _builtin = false; + + public static final Field LATITUDE = new Field("fieldname.latitude", FieldType.COORD); + public static final Field LONGITUDE = new Field("fieldname.longitude", FieldType.COORD); + public static final Field ALTITUDE = new Field("fieldname.altitude", FieldType.INT); + public static final Field TIMESTAMP = new Field("fieldname.timestamp", FieldType.TIME); + public static final Field WAYPT_NAME = new Field("fieldname.waypointname", FieldType.NONE); + 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) + }; + + /** + * Private constructor + * @param inLabelKey Key for label texts + * @param inType type of field + */ + private Field(String inLabelKey, FieldType inType) + { + _labelKey = inLabelKey; + _customLabel = null; + _type = inType; + _builtin = true; + } + + + /** + * Public constructor for custom fields + * @param inLabel label to use for display + */ + public Field(String inLabel) + { + _labelKey = null; + _customLabel = inLabel; + _type = FieldType.NONE; + } + + /** + * @return the name of the field + */ + public String getName() + { + if (_labelKey != null) + return I18nManager.getText(_labelKey); + return _customLabel; + } + + /** + * Change the name of the (non built-in) field + * @param inName new name + */ + public void setName(String inName) + { + if (!isBuiltIn()) _customLabel = inName; + } + + /** + * @return true if this is a built-in field + */ + public boolean isBuiltIn() + { + return _builtin; + } + + /** + * Checks if the two fields are equal + * @param inOther other Field object + * @return true if Fields identical + */ + public boolean equals(Field inOther) + { + return (isBuiltIn() == inOther.isBuiltIn() && getName().equals(inOther.getName())); + } +}