Package org.openstreetmap.josm.data.osm
Class Tag
- java.lang.Object
-
- org.openstreetmap.josm.data.osm.Tag
-
- All Implemented Interfaces:
Serializable
,Map.Entry<String,String>
,Tagged
public class Tag extends Object implements Tagged, Map.Entry<String,String>, 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 String
key
private static long
serialVersionUID
private String
value
-
Fields inherited from interface org.openstreetmap.josm.data.osm.Tagged
MAX_TAG_LENGTH
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
String
get(String k)
Replies the value of the given key; null, if there is no value for this keyString
getKey()
Replies the key of the tag.Map<String,String>
getKeys()
Replies the map of key/value pairs.int
getNumKeys()
Gets the number of keysString
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.Collection<String>
keySet()
Replies the set of keysboolean
matchesKey(String key)
Replies true if the key of this tag is equal tokey
.static Tag
ofString(String s)
This constructs aTag
by splittings
on the first equality sign.void
put(String key, String value)
Unsupported.void
remove(String key)
Unsupported.void
removeAll()
Unsupported.void
setKeys(Map<String,String> keys)
Unsupported.String
setValue(String value)
This is not supported by this implementation.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, visitKeys
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Tag
public Tag()
Create an empty tag whose key and value are empty.
-
Tag
public Tag(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(String key, 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
-
setValue
public String setValue(String value)
This is not supported by this implementation.- Specified by:
setValue
in interfaceMap.Entry<String,String>
- Parameters:
value
- ignored- Returns:
- (Does not return)
- Throws:
UnsupportedOperationException
- always
-
matchesKey
public boolean matchesKey(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()
-
ofString
public static Tag ofString(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
-
setKeys
public void setKeys(Map<String,String> keys)
Unsupported.- Specified by:
setKeys
in interfaceTagged
- Parameters:
keys
- ignored- Throws:
UnsupportedOperationException
- always
-
getKeys
public Map<String,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(String key, String value)
Unsupported.- Specified by:
put
in interfaceTagged
- Parameters:
key
- ignoredvalue
- ignored- Throws:
UnsupportedOperationException
- always
-
get
public String get(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(String key)
Unsupported.- Specified by:
remove
in interfaceTagged
- Parameters:
key
- ignored- Throws:
UnsupportedOperationException
- always
-
hasKeys
public boolean hasKeys()
Description copied from interface:Tagged
Replies true, if there is at least one key/value pair; false, otherwise
-
keySet
public Collection<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.- Specified by:
removeAll
in interfaceTagged
- Throws:
UnsupportedOperationException
- always
-
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
-
-