org.openstreetmap.osmosis.core.domain.v0_5
Class Entity

java.lang.Object
  extended by org.openstreetmap.osmosis.core.domain.v0_5.Entity
All Implemented Interfaces:
Storeable
Direct Known Subclasses:
Bound, Node, Relation, Way

public abstract class Entity
extends java.lang.Object
implements Storeable

A data class representing a single OSM entity. All top level data types inherit from this class.

Author:
Brett Henderson

Constructor Summary
Entity(long id, java.util.Date timestamp, OsmUser user)
          Creates a new instance.
Entity(long id, TimestampContainer timestampContainer, OsmUser user)
          Creates a new instance.
Entity(StoreReader sr, StoreClassRegister scr)
          Creates a new instance.
 
Method Summary
 void addTag(Tag tag)
          Adds a new tag.
 void addTags(java.util.Collection<Tag> tags)
          Adds all tags in the collection to the node.
protected  int compareTags(java.util.List<Tag> comparisonTagList)
          Compares this tag list to the specified tag list.
 java.lang.String getFormattedTimestamp(TimestampFormat timestampFormat)
          Gets the timestamp in a string format.
 long getId()
           
 java.util.List<Tag> getTagList()
          Returns the attached list of tags.
 java.util.Date getTimestamp()
           
abstract  EntityType getType()
          Returns the specific data type represented by this entity.
 OsmUser getUser()
          Returns the user who last edited the entity.
 void store(StoreWriter sw, StoreClassRegister scr)
          Stores all state to the specified store writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Entity

public Entity(long id,
              java.util.Date timestamp,
              OsmUser user)
Creates a new instance.

Parameters:
id - The unique identifier.
timestamp - The last updated timestamp.
user - The user that last modified this entity.

Entity

public Entity(long id,
              TimestampContainer timestampContainer,
              OsmUser user)
Creates a new instance.

Parameters:
id - The unique identifier.
timestampContainer - The container holding the timestamp in an alternative timestamp representation.
user - The user that last modified this entity.

Entity

public Entity(StoreReader sr,
              StoreClassRegister scr)
Creates a new instance.

Parameters:
sr - The store to read state from.
scr - Maintains the mapping between classes and their identifiers within the store.
Method Detail

store

public void store(StoreWriter sw,
                  StoreClassRegister scr)
Stores all state to the specified store writer.

Specified by:
store in interface Storeable
Parameters:
sw - The writer that persists data to an underlying store.
scr - Maintains the mapping between classes and their identifiers within the store.

compareTags

protected int compareTags(java.util.List<Tag> comparisonTagList)
Compares this tag list to the specified tag list. The tag comparison is based on a comparison of key and value in that order.

Parameters:
comparisonTagList - The tagList to compare to.
Returns:
0 if equal, < 0 if considered "smaller", and > 0 if considered "bigger".

getType

public abstract EntityType getType()
Returns the specific data type represented by this entity.

Returns:
The entity type enum value.

getId

public long getId()
Returns:
The id.

getTimestamp

public java.util.Date getTimestamp()
Returns:
The timestamp.

getFormattedTimestamp

public java.lang.String getFormattedTimestamp(TimestampFormat timestampFormat)
Gets the timestamp in a string format. If the entity already contains a string in string format it will return the original unparsed string instead of formatting a date object.

Parameters:
timestampFormat - The formatter to use for formatting the timestamp into a string.
Returns:
The timestamp string.

getUser

public OsmUser getUser()
Returns the user who last edited the entity.

Returns:
The user.

getTagList

public java.util.List<Tag> getTagList()
Returns the attached list of tags. The returned list is read-only.

Returns:
The tagList.

addTag

public void addTag(Tag tag)
Adds a new tag.

Parameters:
tag - The tag to add.

addTags

public void addTags(java.util.Collection<Tag> tags)
Adds all tags in the collection to the node.

Parameters:
tags - The collection of tags to be added.