Package org.openstreetmap.josm.data.osm
Class SimplePrimitiveId
- java.lang.Object
-
- org.openstreetmap.josm.data.osm.SimplePrimitiveId
-
- All Implemented Interfaces:
java.io.Serializable,PrimitiveId
public class SimplePrimitiveId extends java.lang.Object implements PrimitiveId, java.io.Serializable
A primitive id and a primitive type- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private longidstatic java.util.regex.PatternID_PATTERNA pattern that is used to parse a textual primitive idstatic java.util.regex.PatternMULTIPLE_IDS_PATTERNA pattern that is used to parse an id rangeprivate static longserialVersionUIDprivate OsmPrimitiveTypetype
-
Constructor Summary
Constructors Constructor Description SimplePrimitiveId(long id, OsmPrimitiveType type)Create a new primitive id
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)private static java.util.List<SimplePrimitiveId>extractIdsInto(java.util.regex.MatchResult m, java.util.List<SimplePrimitiveId> ids)static SimplePrimitiveIdfromString(java.lang.String s)Parses aSimplePrimitiveIdfrom the strings.static java.util.List<SimplePrimitiveId>fuzzyParse(java.lang.String s)Attempts to parse extract any primitive id from the strings.private static OsmPrimitiveTypegetOsmPrimitiveType(char firstChar)OsmPrimitiveTypegetType()Gets the type of object represented by this object.longgetUniqueId()Gets a unique id representing this object (the OSM server id for OSM objects)inthashCode()booleanisNew()Replies true if this id represents a new primitive.static java.util.List<SimplePrimitiveId>multipleFromString(java.lang.String s)Parses a rangeSimplePrimitiveIdfrom the strings.static java.lang.StringtoSimpleId(PrimitiveId primitive)Convert a primitive to a simple idjava.lang.StringtoString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
id
private final long id
-
type
private final OsmPrimitiveType type
-
ID_PATTERN
public static final java.util.regex.Pattern ID_PATTERN
A pattern that is used to parse a textual primitive id
-
MULTIPLE_IDS_PATTERN
public static final java.util.regex.Pattern MULTIPLE_IDS_PATTERN
A pattern that is used to parse an id range
-
-
Constructor Detail
-
SimplePrimitiveId
public SimplePrimitiveId(long id, OsmPrimitiveType type)
Create a new primitive id- Parameters:
id- The idtype- The type of the primitive
-
-
Method Detail
-
getType
public OsmPrimitiveType getType()
Description copied from interface:PrimitiveIdGets the type of object represented by this object. Note that this should return the base primitive type (OsmPrimitiveType.NODE,OsmPrimitiveType.WAY, andOsmPrimitiveType.RELATION).- Specified by:
getTypein interfacePrimitiveId- Returns:
- the object type
- See Also:
Node,Way,Relation
-
getUniqueId
public long getUniqueId()
Description copied from interface:PrimitiveIdGets a unique id representing this object (the OSM server id for OSM objects)- Specified by:
getUniqueIdin interfacePrimitiveId- Returns:
- the id number
-
isNew
public boolean isNew()
Description copied from interface:PrimitiveIdReplies true if this id represents a new primitive.- Specified by:
isNewin interfacePrimitiveId- Returns:
- true if this id represents a new primitive.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
fromString
public static SimplePrimitiveId fromString(java.lang.String s)
Parses aSimplePrimitiveIdfrom the strings.- Parameters:
s- the string to be parsed, e.g.,n1,node1,w1,way1,r1,rel1,relation1.- Returns:
- the parsed
SimplePrimitiveId - Throws:
java.lang.IllegalArgumentException- if the string does not match the pattern
-
multipleFromString
public static java.util.List<SimplePrimitiveId> multipleFromString(java.lang.String s)
Parses a rangeSimplePrimitiveIdfrom the strings.- Parameters:
s- the string to be parsed, e.g.,node1,node1-7,node70-7.- Returns:
- the parsed
SimplePrimitiveIds - Throws:
java.lang.IllegalArgumentException- if the string does not match the pattern
-
fuzzyParse
public static java.util.List<SimplePrimitiveId> fuzzyParse(java.lang.String s)
Attempts to parse extract any primitive id from the strings.- Parameters:
s- the string to be parsed, e.g.,"n1, w1","node1 and rel2","node 123-29".- Returns:
- the parsed list of
OsmPrimitiveTypes.
-
extractIdsInto
private static java.util.List<SimplePrimitiveId> extractIdsInto(java.util.regex.MatchResult m, java.util.List<SimplePrimitiveId> ids)
-
getOsmPrimitiveType
private static OsmPrimitiveType getOsmPrimitiveType(char firstChar)
-
toSimpleId
public static java.lang.String toSimpleId(PrimitiveId primitive)
Convert a primitive to a simple id- Parameters:
primitive- The primitive to convert- Returns:
- The type (may be n, w, or r, or something else) + the id (e.g., w42)
- Since:
- 18829
-
-