org.openstreetmap.josm.data.osm.history
Class HistoryOsmPrimitive

java.lang.Object
  extended by org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive
All Implemented Interfaces:
java.lang.Comparable<HistoryOsmPrimitive>
Direct Known Subclasses:
HistoryNode, HistoryRelation, HistoryWay

public abstract class HistoryOsmPrimitive
extends java.lang.Object
implements java.lang.Comparable<HistoryOsmPrimitive>

Represents an immutable OSM primitive in the context of a historical view on OSM data.


Field Summary
private  long changesetId
           
private  long id
           
private  java.util.HashMap<java.lang.String,java.lang.String> tags
           
private  java.util.Date timestamp
           
private  User user
           
private  long version
           
private  boolean visible
           
 
Constructor Summary
HistoryOsmPrimitive(long id, long version, boolean visible, User user, long changesetId, java.util.Date timestamp)
          Constructs a new HistoryOsmPrimitive.
HistoryOsmPrimitive(long id, long version, boolean visible, User user, long changesetId, java.util.Date timestamp, boolean checkHistoricParams)
          Constructs a new HistoryOsmPrimitive with a configurable checking of historic parameters.
HistoryOsmPrimitive(OsmPrimitive p)
          Constructs a new HistoryOsmPrimitive from an existing OsmPrimitive.
 
Method Summary
 int compareTo(HistoryOsmPrimitive o)
           
protected  void ensurePositiveLong(long value, java.lang.String name)
           
 boolean equals(java.lang.Object obj)
           
static HistoryOsmPrimitive forOsmPrimitive(OsmPrimitive p)
          Replies a new HistoryNode, HistoryWay or HistoryRelation from an existing OsmPrimitive.
 java.lang.String get(java.lang.String key)
           
 long getChangesetId()
           
abstract  java.lang.String getDisplayName(HistoryNameFormatter formatter)
          Replies the display name of a primitive formatted by formatter
 long getId()
           
 java.lang.String getLocalName()
          Replies the a localized name for this primitive given by the value of the tags (in this order) name:lang_COUNTRY_Variant of the current locale name:lang_COUNTRY of the current locale name:lang of the current locale name of the current locale null, if no such tag exists
 java.lang.String getName()
          Replies the name of this primitive.
 PrimitiveId getPrimitiveId()
           
 java.util.Map<java.lang.String,java.lang.String> getTags()
           
 java.util.Date getTimestamp()
           
abstract  OsmPrimitiveType getType()
           
 User getUser()
           
 long getVersion()
           
 int hashCode()
           
 boolean hasTag(java.lang.String key)
           
 boolean isVisible()
           
 boolean matches(long id)
           
 boolean matches(long id, long version)
           
 void put(java.lang.String key, java.lang.String value)
           
 void setTags(java.util.Map<java.lang.String,java.lang.String> tags)
          Sets the tags for this history primitive.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

id

private long id

visible

private boolean visible

user

private User user

changesetId

private long changesetId

timestamp

private java.util.Date timestamp

version

private long version

tags

private java.util.HashMap<java.lang.String,java.lang.String> tags
Constructor Detail

HistoryOsmPrimitive

public HistoryOsmPrimitive(long id,
                           long version,
                           boolean visible,
                           User user,
                           long changesetId,
                           java.util.Date timestamp)
                    throws java.lang.IllegalArgumentException
Constructs a new HistoryOsmPrimitive.

Parameters:
id - the id (> 0 required)
version - the version (> 0 required)
visible - whether the primitive is still visible
user - the user (! null required)
changesetId - the changeset id (> 0 required)
timestamp - the timestamp (! null required)
Throws:
java.lang.IllegalArgumentException - if preconditions are violated

HistoryOsmPrimitive

public HistoryOsmPrimitive(long id,
                           long version,
                           boolean visible,
                           User user,
                           long changesetId,
                           java.util.Date timestamp,
                           boolean checkHistoricParams)
                    throws java.lang.IllegalArgumentException
Constructs a new HistoryOsmPrimitive with a configurable checking of historic parameters. This is needed to build virtual HistoryOsmPrimitives for modified primitives, which do not have a timestamp and a changeset id.

Parameters:
id - the id (> 0 required)
version - the version (> 0 required)
visible - whether the primitive is still visible
user - the user (! null required)
changesetId - the changeset id (> 0 required if checkHistoricParams is true)
timestamp - the timestamp (! null required if checkHistoricParams is true)
checkHistoricParams - if true, checks values of changesetId and timestamp
Throws:
java.lang.IllegalArgumentException - if preconditions are violated
Since:
5440

HistoryOsmPrimitive

public HistoryOsmPrimitive(OsmPrimitive p)
Constructs a new HistoryOsmPrimitive from an existing OsmPrimitive.

Parameters:
p - the primitive
Method Detail

ensurePositiveLong

protected void ensurePositiveLong(long value,
                                  java.lang.String name)

forOsmPrimitive

public static HistoryOsmPrimitive forOsmPrimitive(OsmPrimitive p)
Replies a new HistoryNode, HistoryWay or HistoryRelation from an existing OsmPrimitive.

Parameters:
p - the primitive
Returns:
a new HistoryNode, HistoryWay or HistoryRelation from p.

getId

public long getId()

getPrimitiveId

public PrimitiveId getPrimitiveId()

isVisible

public boolean isVisible()

getUser

public User getUser()

getChangesetId

public long getChangesetId()

getTimestamp

public java.util.Date getTimestamp()

getVersion

public long getVersion()

matches

public boolean matches(long id,
                       long version)

matches

public boolean matches(long id)

getType

public abstract OsmPrimitiveType getType()

compareTo

public int compareTo(HistoryOsmPrimitive o)
Specified by:
compareTo in interface java.lang.Comparable<HistoryOsmPrimitive>

put

public void put(java.lang.String key,
                java.lang.String value)

get

public java.lang.String get(java.lang.String key)

hasTag

public boolean hasTag(java.lang.String key)

getTags

public java.util.Map<java.lang.String,java.lang.String> getTags()

setTags

public void setTags(java.util.Map<java.lang.String,java.lang.String> tags)
Sets the tags for this history primitive. Removes all tags if tags is null.

Parameters:
tags - the tags. May be null.

getName

public java.lang.String getName()
Replies the name of this primitive. The default implementation replies the value of the tag name or null, if this tag is not present.

Returns:
the name of this primitive

getDisplayName

public abstract java.lang.String getDisplayName(HistoryNameFormatter formatter)
Replies the display name of a primitive formatted by formatter

Parameters:
formatter - The formatter used to generate a display name
Returns:
the display name

getLocalName

public java.lang.String getLocalName()
Replies the a localized name for this primitive given by the value of the tags (in this order) null, if no such tag exists

Returns:
the name of this primitive

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


JOSM