us.zuercher.gpx2map.data
Class AbstractGpxEntity

java.lang.Object
  extended by us.zuercher.gpx2map.data.AbstractGpxEntity
Direct Known Subclasses:
Route, Track, WayPoint

public abstract class AbstractGpxEntity
extends Object

AbstractGpxEntity is an abstract base class for entities in a GPX file. Entities are items such as way-points, track-points or route-points each of which contain properties of various types.

Subclasses of AbstractGpxEntity provide sets of property names that are associated with property types.

Author:
Stephan Zuercher

Field Summary
protected static SimpleDateFormat dateFormatter
          Used to format date/time properties output via toString().
private  Map<String,Object> properties
          Map of property names to propery values, across types.
 
Constructor Summary
AbstractGpxEntity()
          Construct a new AbstractGpxEntity.
 
Method Summary
 boolean equals(AbstractGpxEntity other)
          Compare this AbstractGpxEntity to another for equality, based on properties.
 boolean equals(Object other)
          Compare this AbstractGpxEntity to another for equality, based on properties.
 Date getDateTimeProperty(String propertyName)
          Retrieves the value of the given date/time property.
abstract  Set<String> getDateTimePropertyNames()
          Returns a set of property names that refer to date/time properties.
 Double getDecimalProperty(String propertyName)
          Retrieves the value of the given decimal property.
abstract  Set<String> getDecimalPropertyNames()
          Returns a set of property names that refer to decimal properties.
 Integer getIntegerProperty(String propertyName)
          Retrieves the value of the given integer property.
abstract  Set<String> getIntegerPropertyNames()
          Returns a set of property names that refer to integer properties.
 String getStringProperty(String propertyName)
          Retrieves the value of the given string property.
abstract  Set<String> getStringPropertyNames()
          Returns a set of property names that refer to string properties.
 int hashCode()
          Compute a reasonable hash code for this AbstractGpxEntity.
 void setDateTimeProperty(String propertyName, Date value)
          Sets the given date/time property to the given value.
 void setDecimalProperty(String propertyName, double value)
          Sets the given decimal property to the given value.
 void setIntegerProperty(String propertyName, int value)
          Sets the given integer property to the given value.
 void setStringProperty(String propertyName, String value)
          Sets the given string property to the given value.
 String toString()
          Return a string representation of this AbstractGpxEntity's properties.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

dateFormatter

protected static final SimpleDateFormat dateFormatter
Used to format date/time properties output via toString().


properties

private final Map<String,Object> properties
Map of property names to propery values, across types.

Constructor Detail

AbstractGpxEntity

AbstractGpxEntity()
Construct a new AbstractGpxEntity.

Method Detail

getStringPropertyNames

public abstract Set<String> getStringPropertyNames()
Returns a set of property names that refer to string properties.

Returns:
a set of property names that refer to string properties.

getDecimalPropertyNames

public abstract Set<String> getDecimalPropertyNames()
Returns a set of property names that refer to decimal properties.

Returns:
a set of property names that refer to decimal properties.

getIntegerPropertyNames

public abstract Set<String> getIntegerPropertyNames()
Returns a set of property names that refer to integer properties.

Returns:
a set of property names that refer to integer properties.

getDateTimePropertyNames

public abstract Set<String> getDateTimePropertyNames()
Returns a set of property names that refer to date/time properties.

Returns:
a set of property names that refer to date/time properties.

getStringProperty

public String getStringProperty(String propertyName)
Retrieves the value of the given string property.

Parameters:
propertyName - the name of a string property
Returns:
the property's value or null if it is not set or if the property name does not refer to a string property.

setStringProperty

public void setStringProperty(String propertyName,
                              String value)
Sets the given string property to the given value.

Parameters:
propertyName - property's name
value - value to set
Throws:
IllegalArgumentException - if propertyName does not refer to a string property

getDecimalProperty

public Double getDecimalProperty(String propertyName)
Retrieves the value of the given decimal property.

Parameters:
propertyName - the name of a decimal property
Returns:
the property's value or null if it is not set or if the property name does not refer to a decimal property.

setDecimalProperty

public void setDecimalProperty(String propertyName,
                               double value)
Sets the given decimal property to the given value.

Parameters:
propertyName - property's name
value - value to set
Throws:
IllegalArgumentException - if propertyName does not refer to a decimal property

getIntegerProperty

public Integer getIntegerProperty(String propertyName)
Retrieves the value of the given integer property.

Parameters:
propertyName - the name of an integer property
Returns:
the property's value or null if it is not set or if the property name does not refer to an integer property.

setIntegerProperty

public void setIntegerProperty(String propertyName,
                               int value)
Sets the given integer property to the given value.

Parameters:
propertyName - property's name
value - value to set
Throws:
IllegalArgumentException - if propertyName does not refer to an integer property

getDateTimeProperty

public Date getDateTimeProperty(String propertyName)
Retrieves the value of the given date/time property.

Parameters:
propertyName - the name of a date/time property
Returns:
the property's value or null if it is not set or if the property name does not refer to a date/time property.

setDateTimeProperty

public void setDateTimeProperty(String propertyName,
                                Date value)
Sets the given date/time property to the given value.

Parameters:
propertyName - property's name
value - value to set
Throws:
IllegalArgumentException - if propertyName does not refer to a date/time property

equals

public boolean equals(AbstractGpxEntity other)
Compare this AbstractGpxEntity to another for equality, based on properties. This method is normally used by subclasses.

Parameters:
other - the other AbstractGpxEntity
Returns:
true if the AbstractGpxEntity properties are equal

equals

public boolean equals(Object other)
Compare this AbstractGpxEntity to another for equality, based on properties. This method is normally used by subclasses.

Overrides:
equals in class Object
Parameters:
other - the other AbstractGpxEntity
Returns:
true if the AbstractGpxEntity properties are equal
Throws:
ClassCastException - if other is not an AbstractGpxEntity

hashCode

public int hashCode()
Compute a reasonable hash code for this AbstractGpxEntity. Typically called by subclasses.

Overrides:
hashCode in class Object
Returns:
a hash code for this AbstractGpxEntity

toString

public String toString()
Return a string representation of this AbstractGpxEntity's properties.

Overrides:
toString in class Object
Returns:
string representation of this AbstractGpxEntity's properties.