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
Tagged
interface. 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.String
key
private static long
serialVersionUID
private java.lang.String
value
-
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 iskey
and 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 boolean
equals(java.lang.Object obj)
java.lang.String
get(java.lang.String k)
Replies the value of the given key; null, if there is no value for this keyjava.lang.String
getKey()
Replies the key of the tag.java.util.Map<java.lang.String,java.lang.String>
getKeys()
Replies the map of key/value pairs.int
getNumKeys()
Gets the number of keysjava.lang.String
getValue()
Replies the value of the tag.int
hashCode()
boolean
hasKeys()
Replies true, if there is at least one key/value pair; false, otherwiseboolean
isDirectionKey()
true if this is a direction dependent tag (e.g.java.util.Collection<java.lang.String>
keySet()
Replies the set of keysboolean
matchesKey(java.lang.String key)
Replies true if the key of this tag is equal tokey
.static Tag
ofString(java.lang.String s)
This constructs aTag
by splittings
on the first equality sign.void
put(java.lang.String key, java.lang.String value)
Unsupported.void
remove(java.lang.String key)
Unsupported.void
removeAll()
Unsupported.void
setKeys(java.util.Map<java.lang.String,java.lang.String> keys)
Unsupported.java.lang.String
setValue(java.lang.String value)
This is not supported by this implementation.java.lang.String
toString()
-
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 iskey
and 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:
getKey
in 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:
getValue
in 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:
setValue
in 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
. Ifkey
is 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:
hashCode
in interfacejava.util.Map.Entry<java.lang.String,java.lang.String>
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfacejava.util.Map.Entry<java.lang.String,java.lang.String>
- Overrides:
equals
in classjava.lang.Object
-
ofString
public static Tag ofString(java.lang.String s)
This constructs aTag
by splittings
on the first equality sign.- Parameters:
s
- the string to convert- Returns:
- the constructed tag
- See Also:
TextTagParser
-
toString
public java.lang.String toString()
- Overrides:
toString
in 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:Tagged
Replies 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:Tagged
Replies 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:Tagged
Replies 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:Tagged
Replies the set of keys- Specified by:
keySet
in interfaceTagged
- Returns:
- the set of keys
- See Also:
Tagged.keys()
-
getNumKeys
public final int getNumKeys()
Description copied from interface:Tagged
Gets the number of keys- Specified by:
getNumKeys
in 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:
true
if this is is a direction dependent tag- Since:
- 10716
-
-