us.zuercher.gpx2map.data
Class Track

java.lang.Object
  extended by us.zuercher.gpx2map.data.AbstractGpxEntity
      extended by us.zuercher.gpx2map.data.Track
All Implemented Interfaces:
Iterable<TrackPoint>

public class Track
extends AbstractGpxEntity
implements Iterable<TrackPoint>

Track represents a GPX track. Tracks are made up of zero or more TrackSegment objects.

Track supports the following properties:

Name Type
name string
cmt string
desc string
src string
link string
type string
numberinteger

Author:
Stephan Zuercher

Nested Class Summary
private static class Track.TrackPointIterator
          TrackPointIterator iterates over TrackPoints across TrackSegments.
 
Field Summary
private static Set<String> integerPropertyNames
          Integer property names.
private static List<String> nameLikePropertyNames
          Subset of stringPropertyNames.
private  List<TrackSegment> segments
          The TrackSegments that comprise this Track.
private static Set<String> stringPropertyNames
          String property names.
 
Fields inherited from class us.zuercher.gpx2map.data.AbstractGpxEntity
dateFormatter
 
Constructor Summary
Track()
          Constructs a new Track.
 
Method Summary
 void addTrackSegment(TrackSegment segment)
          Adds a TrackSegment to this Track.
 boolean equals(Object other)
          Tests whether this Track is equal to another.
 boolean equals(Track other)
          Tests whether this Track is equal to another.
 Set<String> getDateTimePropertyNames()
          Returns an empty set.
 Set<String> getDecimalPropertyNames()
          Returns an empty set.
 Set<String> getIntegerPropertyNames()
          Returns the Track's integer property names.
 String getName()
          Get this Track's name.
 Set<String> getStringPropertyNames()
          Returns the Track's string property names.
 int hashCode()
          Computes a reasonable hash code for this Track.
 Iterator<TrackPoint> iterator()
          Returns an Track.TrackPointIterator over all TrackPoints contained in this Track's TrackSegments.
 Iterator<TrackSegment> segmentIterator()
          Returns an Track.TrackPointIterator over this Track's TrackSegments.
 String toExtendedString(String lineSep)
          Returns a string representation of this Track based on the Track's properties and TrackPoints.
 String toString()
          Returns a simple string representation of this Track based on the track's name, if any.
 
Methods inherited from class us.zuercher.gpx2map.data.AbstractGpxEntity
equals, getDateTimeProperty, getDecimalProperty, getIntegerProperty, getStringProperty, setDateTimeProperty, setDecimalProperty, setIntegerProperty, setStringProperty
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

stringPropertyNames

private static final Set<String> stringPropertyNames
String property names.


nameLikePropertyNames

private static final List<String> nameLikePropertyNames
Subset of stringPropertyNames.


integerPropertyNames

private static final Set<String> integerPropertyNames
Integer property names.


segments

private final List<TrackSegment> segments
The TrackSegments that comprise this Track.

Constructor Detail

Track

public Track()
Constructs a new Track.

Method Detail

getName

public String getName()
Get this Track's name. The name is the first of any of the nameLikePropertyNames set for this track.

Returns:
track's name, if available.

addTrackSegment

public void addTrackSegment(TrackSegment segment)
Adds a TrackSegment to this Track.

Parameters:
segment - the TrackSegment to add.

segmentIterator

public Iterator<TrackSegment> segmentIterator()
Returns an Track.TrackPointIterator over this Track's TrackSegments.

Returns:
an Track.TrackPointIterator over this Track's TrackSegments.

iterator

public Iterator<TrackPoint> iterator()
Returns an Track.TrackPointIterator over all TrackPoints contained in this Track's TrackSegments.

Specified by:
iterator in interface Iterable<TrackPoint>
Returns:
an Track.TrackPointIterator over all TrackPoints contained in this Track's TrackSegments.
See Also:
Track.TrackPointIterator

hashCode

public int hashCode()
Computes a reasonable hash code for this Track.

Overrides:
hashCode in class AbstractGpxEntity
Returns:
a reasonable hash code for this Track.

equals

public boolean equals(Track other)
Tests whether this Track is equal to another. Equality requires all Track properties and TrackPoints to be equal.

Parameters:
other - another Track
Returns:
true if the tracks are equal, false otherwise

equals

public boolean equals(Object other)
Tests whether this Track is equal to another. Equality requires all Track properties and TrackPoints to be equal.

Overrides:
equals in class AbstractGpxEntity
Parameters:
other - another Track
Returns:
true if the tracks are equal, false otherwise
Throws:
ClassCastException - if other is not a Track

toString

public String toString()
Returns a simple string representation of this Track based on the track's name, if any.

Overrides:
toString in class AbstractGpxEntity
Returns:
a string representation of this Track.

toExtendedString

public String toExtendedString(String lineSep)
Returns a string representation of this Track based on the Track's properties and TrackPoints.

Parameters:
lineSep - line separate character
Returns:
string representation of this Track.

getStringPropertyNames

public Set<String> getStringPropertyNames()
Returns the Track's string property names.

Specified by:
getStringPropertyNames in class AbstractGpxEntity
Returns:
the Track's string property names.
See Also:
AbstractGpxEntity.getStringPropertyNames()

getDecimalPropertyNames

public Set<String> getDecimalPropertyNames()
Returns an empty set. Tracks have no decimal properties.

Specified by:
getDecimalPropertyNames in class AbstractGpxEntity
Returns:
an empty set.
See Also:
AbstractGpxEntity.getDecimalPropertyNames()

getIntegerPropertyNames

public Set<String> getIntegerPropertyNames()
Returns the Track's integer property names.

Specified by:
getIntegerPropertyNames in class AbstractGpxEntity
Returns:
the Track's integer property names.
See Also:
AbstractGpxEntity.getIntegerPropertyNames()

getDateTimePropertyNames

public Set<String> getDateTimePropertyNames()
Returns an empty set. Tracks have no date/tiem properties.

Specified by:
getDateTimePropertyNames in class AbstractGpxEntity
Returns:
an empty set.
See Also:
AbstractGpxEntity.getDateTimePropertyNames()