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

java.lang.Object
  extended by org.openstreetmap.osmosis.core.domain.v0_5.Entity
      extended by org.openstreetmap.osmosis.core.domain.v0_5.Relation
All Implemented Interfaces:
java.lang.Comparable<Relation>, Storeable

public class Relation
extends Entity
implements java.lang.Comparable<Relation>

A data class representing a single OSM relation.

Author:
Brett Henderson

Constructor Summary
Relation(long id, java.util.Date timestamp, OsmUser user)
          Creates a new instance.
Relation(long id, TimestampContainer timestampContainer, OsmUser user)
          Creates a new instance.
Relation(StoreReader sr, StoreClassRegister scr)
          Creates a new instance.
 
Method Summary
 void addMember(RelationMember member)
          Adds a new member.
 void addMembers(java.util.Collection<RelationMember> members)
          Adds all members in the collection to the relation.
protected  int compareMemberList(java.util.List<RelationMember> comparisonMemberList)
          Compares this member list to the specified member list.
 int compareTo(Relation comparisonRelation)
          Compares this relation to the specified relation.
 boolean equals(java.lang.Object o)
          
 java.util.List<RelationMember> getMemberList()
          Returns the attached list of relation members.
 EntityType getType()
          Returns the specific data type represented by this entity.
 int hashCode()
          
 void store(StoreWriter sw, StoreClassRegister scr)
          Stores all state to the specified store writer.
 
Methods inherited from class org.openstreetmap.osmosis.core.domain.v0_5.Entity
addTag, addTags, compareTags, getFormattedTimestamp, getId, getTagList, getTimestamp, getUser
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Relation

public Relation(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.

Relation

public Relation(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.

Relation

public Relation(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
Overrides:
store in class Entity
Parameters:
sw - The writer that persists data to an underlying store.
scr - Maintains the mapping between classes and their identifiers within the store.

getType

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

Specified by:
getType in class Entity
Returns:
The entity type enum value.

equals

public boolean equals(java.lang.Object o)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

compareMemberList

protected int compareMemberList(java.util.List<RelationMember> comparisonMemberList)
Compares this member list to the specified member list. The bigger list is considered bigger, if that is equal then each relation member is compared.

Parameters:
comparisonMemberList - The member list to compare to.
Returns:
0 if equal, < 0 if considered "smaller", and > 0 if considered "bigger".

compareTo

public int compareTo(Relation comparisonRelation)
Compares this relation to the specified relation. The relation comparison is based on a comparison of id, timestamp, and tags in that order.

Specified by:
compareTo in interface java.lang.Comparable<Relation>
Parameters:
comparisonRelation - The relation to compare to.
Returns:
0 if equal, < 0 if considered "smaller", and > 0 if considered "bigger".

getMemberList

public java.util.List<RelationMember> getMemberList()
Returns the attached list of relation members. The returned list is read-only.

Returns:
The member list.

addMember

public void addMember(RelationMember member)
Adds a new member.

Parameters:
member - The member to add.

addMembers

public void addMembers(java.util.Collection<RelationMember> members)
Adds all members in the collection to the relation.

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