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

java.lang.Object
  extended by org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive
      extended by org.openstreetmap.josm.data.osm.history.HistoryRelation
All Implemented Interfaces:
java.lang.Comparable<HistoryOsmPrimitive>

public class HistoryRelation
extends HistoryOsmPrimitive

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


Field Summary
private  java.util.ArrayList<RelationMemberData> members
           
 
Constructor Summary
HistoryRelation(long id, long version, boolean visible, User user, long changesetId, java.util.Date timestamp)
          constructor
HistoryRelation(long id, long version, boolean visible, User user, long changesetId, java.util.Date timestamp, java.util.ArrayList<RelationMemberData> members)
          constructor
HistoryRelation(long id, long version, boolean visible, User user, long changesetId, java.util.Date timestamp, boolean checkHistoricParams)
          constructor
HistoryRelation(Relation r)
          Constructs a new HistoryRelation from an existing Relation.
 
Method Summary
 void addMember(RelationMemberData member)
          adds a member to the list of members
 java.lang.String getDisplayName(HistoryNameFormatter formatter)
          Replies the display name of a primitive formatted by formatter
 java.util.List<RelationMemberData> getMembers()
          replies an immutable list of members of this relation
 int getNumMembers()
          replies the number of members
 RelationMemberData getRelationMember(int idx)
          replies the idx-th member
 OsmPrimitiveType getType()
          replies the type, i.e.
 
Methods inherited from class org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive
compareTo, ensurePositiveLong, equals, forOsmPrimitive, get, getChangesetId, getId, getLocalName, getName, getPrimitiveId, getTags, getTimestamp, getUser, getVersion, hashCode, hasTag, isVisible, matches, matches, put, setTags, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

members

private java.util.ArrayList<RelationMemberData> members
Constructor Detail

HistoryRelation

public HistoryRelation(long id,
                       long version,
                       boolean visible,
                       User user,
                       long changesetId,
                       java.util.Date timestamp)
                throws java.lang.IllegalArgumentException
constructor

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

HistoryRelation

public HistoryRelation(long id,
                       long version,
                       boolean visible,
                       User user,
                       long changesetId,
                       java.util.Date timestamp,
                       boolean checkHistoricParams)
                throws java.lang.IllegalArgumentException
constructor

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

HistoryRelation

public HistoryRelation(long id,
                       long version,
                       boolean visible,
                       User user,
                       long changesetId,
                       java.util.Date timestamp,
                       java.util.ArrayList<RelationMemberData> members)
constructor

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)
members - list of members for this relation
Throws:
java.lang.IllegalArgumentException - thrown if preconditions are violated

HistoryRelation

public HistoryRelation(Relation r)
Constructs a new HistoryRelation from an existing Relation.

Parameters:
r - the relation
Method Detail

getMembers

public java.util.List<RelationMemberData> getMembers()
replies an immutable list of members of this relation

Returns:
an immutable list of members of this relation

getNumMembers

public int getNumMembers()
replies the number of members

Returns:
the number of members

getRelationMember

public RelationMemberData getRelationMember(int idx)
                                     throws java.lang.IndexOutOfBoundsException
replies the idx-th member

Parameters:
idx - the index
Returns:
the idx-th member
Throws:
java.lang.IndexOutOfBoundsException - thrown, if idx is out of bounds

getType

public OsmPrimitiveType getType()
replies the type, i.e. OsmPrimitiveType.RELATION

Specified by:
getType in class HistoryOsmPrimitive

addMember

public void addMember(RelationMemberData member)
               throws java.lang.IllegalArgumentException
adds a member to the list of members

Parameters:
member - the member (must not be null)
Throws:
java.lang.IllegalArgumentException - thrown, if member is null

getDisplayName

public java.lang.String getDisplayName(HistoryNameFormatter formatter)
Description copied from class: HistoryOsmPrimitive
Replies the display name of a primitive formatted by formatter

Specified by:
getDisplayName in class HistoryOsmPrimitive
Parameters:
formatter - The formatter used to generate a display name
Returns:
the display name


JOSM