Package org.openstreetmap.josm.data.osm
Class Tag
- java.lang.Object
-
- org.openstreetmap.josm.data.osm.Tag
-
- All Implemented Interfaces:
java.io.Serializable,java.util.Map.Entry<java.lang.String,java.lang.String>,Tagged
public class Tag extends java.lang.Object implements Tagged, java.util.Map.Entry<java.lang.String,java.lang.String>, java.io.Serializable
Tag represents an immutable key/value-pair. Both the key and the value may be empty, but not null.It implements the
Taggedinterface. However, since instances of this class are immutable, the modifying methods throw anUnsupportedOperationException.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringkeyprivate static longserialVersionUIDprivate java.lang.Stringvalue-
Fields inherited from interface org.openstreetmap.josm.data.osm.Tagged
MAX_TAG_LENGTH
-
-
Constructor Summary
Constructors Constructor Description Tag()Create an empty tag whose key and value are empty.Tag(java.lang.String key)Create a tag whose key iskeyand whose value is empty.Tag(java.lang.String key, java.lang.String value)Creates a tag for a key and a value.Tag(Tag tag)Creates clone of the tagtag.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)java.lang.Stringget(java.lang.String k)Replies the value of the given key; null, if there is no value for this keyjava.lang.StringgetKey()Replies the key of the tag.java.util.Map<java.lang.String,java.lang.String>getKeys()Replies the map of key/value pairs.intgetNumKeys()Gets the number of keysjava.lang.StringgetValue()Replies the value of the tag.inthashCode()booleanhasKeys()Replies true, if there is at least one key/value pair; false, otherwisebooleanisDirectionKey()true if this is a direction dependent tag (e.g.java.util.Collection<java.lang.String>keySet()Replies the set of keysbooleanmatchesKey(java.lang.String key)Replies true if the key of this tag is equal tokey.static TagofString(java.lang.String s)This constructs aTagby splittingson the first equality sign.voidput(java.lang.String key, java.lang.String value)Unsupported.voidremove(java.lang.String key)Unsupported.voidremoveAll()Unsupported.voidsetKeys(java.util.Map<java.lang.String,java.lang.String> keys)Unsupported.java.lang.StringsetValue(java.lang.String value)This is not supported by this implementation.java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.data.osm.Tagged
hasKey, hasTag, hasTag, hasTag, hasTag, hasTagDifferent, hasTagDifferent, hasTagDifferent, isKeyFalse, isKeyTrue, keys, put, putAll, visitKeys
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
key
private final java.lang.String key
-
value
private final java.lang.String value
-
-
Constructor Detail
-
Tag
public Tag()
Create an empty tag whose key and value are empty.
-
Tag
public Tag(java.lang.String key)
Create a tag whose key iskeyand whose value is empty.- Parameters:
key- the key. If null, it is set to the empty key.
-
Tag
public Tag(java.lang.String key, java.lang.String value)
Creates a tag for a key and a value. If key and/or value are null, the empty value "" is assumed.- Parameters:
key- the keyvalue- the value
-
-
Method Detail
-
getKey
public java.lang.String getKey()
Replies the key of the tag. This is never null.- Specified by:
getKeyin interfacejava.util.Map.Entry<java.lang.String,java.lang.String>- Returns:
- the key of the tag
-
getValue
public java.lang.String getValue()
Replies the value of the tag. This is never null.- Specified by:
getValuein interfacejava.util.Map.Entry<java.lang.String,java.lang.String>- Returns:
- the value of the tag
-
setValue
public java.lang.String setValue(java.lang.String value)
This is not supported by this implementation.- Specified by:
setValuein interfacejava.util.Map.Entry<java.lang.String,java.lang.String>- Parameters:
value- ignored- Returns:
- (Does not return)
- Throws:
java.lang.UnsupportedOperationException- always
-
matchesKey
public boolean matchesKey(java.lang.String key)
Replies true if the key of this tag is equal tokey. Ifkeyis null, assumes the empty key.- Parameters:
key- the key- Returns:
- true if the key of this tag is equal to
key
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Map.Entry<java.lang.String,java.lang.String>- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin interfacejava.util.Map.Entry<java.lang.String,java.lang.String>- Overrides:
equalsin classjava.lang.Object
-
ofString
public static Tag ofString(java.lang.String s)
This constructs aTagby splittingson the first equality sign.- Parameters:
s- the string to convert- Returns:
- the constructed tag
- See Also:
TextTagParser
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setKeys
public void setKeys(java.util.Map<java.lang.String,java.lang.String> keys)
Unsupported.
-
getKeys
public java.util.Map<java.lang.String,java.lang.String> getKeys()
Description copied from interface:TaggedReplies the map of key/value pairs. Never null, but may be the empty map.
-
put
public void put(java.lang.String key, java.lang.String value)
Unsupported.
-
get
public java.lang.String get(java.lang.String k)
Description copied from interface:TaggedReplies the value of the given key; null, if there is no value for this key
-
remove
public void remove(java.lang.String key)
Unsupported.
-
hasKeys
public boolean hasKeys()
Description copied from interface:TaggedReplies true, if there is at least one key/value pair; false, otherwise
-
keySet
public java.util.Collection<java.lang.String> keySet()
Description copied from interface:TaggedReplies the set of keys- Specified by:
keySetin interfaceTagged- Returns:
- the set of keys
- See Also:
Tagged.keys()
-
getNumKeys
public final int getNumKeys()
Description copied from interface:TaggedGets the number of keys- Specified by:
getNumKeysin interfaceTagged- Returns:
- The number of keys set for this tagged object.
-
removeAll
public void removeAll()
Unsupported.
-
isDirectionKey
public boolean isDirectionKey()
true if this is a direction dependent tag (e.g. oneway)- Returns:
trueif this is is a direction dependent tag- Since:
- 10716
-
-