Package org.openstreetmap.josm.data.osm
Interface Tagged
-
- All Known Subinterfaces:
INode
,IPrimitive
,IRelation<M>
,IWay<N>
- All Known Implementing Classes:
AbstractPrimitive
,Changeset
,HistoryNode
,HistoryOsmPrimitive
,HistoryRelation
,HistoryWay
,Node
,NodeData
,OsmPrimitive
,PrimitiveData
,Relation
,RelationData
,Tag
,VectorNode
,VectorPrimitive
,VectorRelation
,VectorWay
,Way
,WayData
public interface Tagged
Objects implement Tagged if they provide a map of key/value pairs.- Since:
- 2115
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_TAG_LENGTH
The maximum tag length allowed by OSM API
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.String
get(java.lang.String key)
Replies the value of the given key; null, if there is no value for this keyjava.util.Map<java.lang.String,java.lang.String>
getKeys()
Replies the map of key/value pairs.int
getNumKeys()
Gets the number of keysdefault boolean
hasKey(java.lang.String key)
Replies true if there is a tag with keykey
.boolean
hasKeys()
Replies true, if there is at least one key/value pair; false, otherwisedefault boolean
hasTag(java.lang.String key)
Replies true if there is a non-empty tag with keykey
.default boolean
hasTag(java.lang.String key, java.lang.String value)
Tests whether this primitive contains a tag consisting ofkey
andvalue
.default boolean
hasTag(java.lang.String key, java.lang.String... values)
Tests whether this primitive contains a tag consisting ofkey
and any ofvalues
.default boolean
hasTag(java.lang.String key, java.util.Collection<java.lang.String> values)
Tests whether this primitive contains a tag consisting ofkey
and any ofvalues
.default boolean
hasTagDifferent(java.lang.String key, java.lang.String value)
Tests whether this primitive contains a tag consisting ofkey
and a value different fromvalue
.default boolean
hasTagDifferent(java.lang.String key, java.lang.String... values)
Tests whether this primitive contains a tag consisting ofkey
and none ofvalues
.default boolean
hasTagDifferent(java.lang.String key, java.util.Collection<java.lang.String> values)
Tests whether this primitive contains a tag consisting ofkey
and none ofvalues
.default boolean
isKeyFalse(java.lang.String key)
Returns true if thekey
corresponds to an OSM false value.default boolean
isKeyTrue(java.lang.String key)
Returns true if thekey
corresponds to an OSM true value.default java.util.stream.Stream<java.lang.String>
keys()
Replies the keys as streamjava.util.Collection<java.lang.String>
keySet()
Replies the set of keysstatic Tagged
ofMap(java.util.Map<java.lang.String,java.lang.String> tags)
Returns a Tagged instance for the given tag mapstatic Tagged
ofTags(java.util.Collection<Tag> tags)
Returns a Tagged instance for the given tag collectionvoid
put(java.lang.String key, java.lang.String value)
Sets a key/value pairsdefault void
put(Tag tag)
Sets a key/value pairsdefault void
putAll(java.util.Map<java.lang.String,java.lang.String> tags)
Add all key/value pairs.void
remove(java.lang.String key)
Removes a given key/value pairvoid
removeAll()
Removes all tagsvoid
setKeys(java.util.Map<java.lang.String,java.lang.String> keys)
Sets the map of key/value pairsdefault void
visitKeys(KeyValueVisitor visitor)
Calls the visitor for every key/value pair.
-
-
-
Field Detail
-
MAX_TAG_LENGTH
static final int MAX_TAG_LENGTH
The maximum tag length allowed by OSM API- Since:
- 13414
- See Also:
- Constant Field Values
-
-
Method Detail
-
setKeys
void setKeys(java.util.Map<java.lang.String,java.lang.String> keys)
Sets the map of key/value pairs- Parameters:
keys
- the map of key value pairs. If null, reset to the empty map.
-
getKeys
java.util.Map<java.lang.String,java.lang.String> getKeys()
Replies the map of key/value pairs. Never null, but may be the empty map.- Returns:
- the map of key/value pairs
-
visitKeys
default void visitKeys(KeyValueVisitor visitor)
Calls the visitor for every key/value pair.- Parameters:
visitor
- The visitor to call.- Since:
- 13668
- See Also:
getKeys()
-
put
void put(java.lang.String key, java.lang.String value)
Sets a key/value pairs- Parameters:
key
- the keyvalue
- the value. If null, removes the key/value pair.
-
put
default void put(Tag tag)
Sets a key/value pairs- Parameters:
tag
- The tag to set.- Since:
- 10736
-
putAll
default void putAll(java.util.Map<java.lang.String,java.lang.String> tags)
Add all key/value pairs. This may be more performant thanput(java.lang.String, java.lang.String)
, depending upon the implementation. By default, this callsput(java.lang.String, java.lang.String)
for each map entry.- Parameters:
tags
- The tag map to add- Since:
- 18473
-
get
java.lang.String get(java.lang.String key)
Replies the value of the given key; null, if there is no value for this key- Parameters:
key
- the key- Returns:
- the value
-
remove
void remove(java.lang.String key)
Removes a given key/value pair- Parameters:
key
- the key
-
hasKeys
boolean hasKeys()
Replies true, if there is at least one key/value pair; false, otherwise- Returns:
- true, if there is at least one key/value pair; false, otherwise
-
hasKey
default boolean hasKey(java.lang.String key)
Replies true if there is a tag with keykey
. The value could however be empty. SeehasTag(String)
to check for non-empty tags.- Parameters:
key
- the key- Returns:
- true, if there is a tag with key
key
- Since:
- 11608
- See Also:
hasTag(String)
-
hasTag
default boolean hasTag(java.lang.String key)
Replies true if there is a non-empty tag with keykey
.- Parameters:
key
- the key- Returns:
- true, if there is a non-empty tag with key
key
- Since:
- 13430
- See Also:
hasKey(String)
-
hasTag
default boolean hasTag(java.lang.String key, java.lang.String value)
Tests whether this primitive contains a tag consisting ofkey
andvalue
.- Parameters:
key
- the key forming the tag.value
- value forming the tag.- Returns:
- true if primitive contains a tag consisting of
key
andvalue
. - Since:
- 13668
-
hasTag
default boolean hasTag(java.lang.String key, java.lang.String... values)
Tests whether this primitive contains a tag consisting ofkey
and any ofvalues
.- Parameters:
key
- the key forming the tag.values
- one or many values forming the tag.- Returns:
- true if primitive contains a tag consisting of
key
and any ofvalues
. - Since:
- 13668
-
hasTag
default boolean hasTag(java.lang.String key, java.util.Collection<java.lang.String> values)
Tests whether this primitive contains a tag consisting ofkey
and any ofvalues
.- Parameters:
key
- the key forming the tag.values
- one or many values forming the tag.- Returns:
- true if primitive contains a tag consisting of
key
and any ofvalues
. - Since:
- 13668
-
hasTagDifferent
default boolean hasTagDifferent(java.lang.String key, java.lang.String value)
Tests whether this primitive contains a tag consisting ofkey
and a value different fromvalue
.- Parameters:
key
- the key forming the tag.value
- value not forming the tag.- Returns:
- true if primitive contains a tag consisting of
key
and a value different fromvalue
. - Since:
- 13668
-
hasTagDifferent
default boolean hasTagDifferent(java.lang.String key, java.lang.String... values)
Tests whether this primitive contains a tag consisting ofkey
and none ofvalues
.- Parameters:
key
- the key forming the tag.values
- one or many values forming the tag.- Returns:
- true if primitive contains a tag consisting of
key
and none ofvalues
. - Since:
- 13668
-
hasTagDifferent
default boolean hasTagDifferent(java.lang.String key, java.util.Collection<java.lang.String> values)
Tests whether this primitive contains a tag consisting ofkey
and none ofvalues
.- Parameters:
key
- the key forming the tag.values
- one or many values forming the tag.- Returns:
- true if primitive contains a tag consisting of
key
and none ofvalues
. - Since:
- 13668
-
keySet
java.util.Collection<java.lang.String> keySet()
Replies the set of keys- Returns:
- the set of keys
- See Also:
keys()
-
keys
default java.util.stream.Stream<java.lang.String> keys()
Replies the keys as stream- Returns:
- the keys as stream
- Since:
- 17584
- See Also:
keySet()
-
getNumKeys
int getNumKeys()
Gets the number of keys- Returns:
- The number of keys set for this tagged object.
- Since:
- 13625
-
removeAll
void removeAll()
Removes all tags
-
isKeyTrue
default boolean isKeyTrue(java.lang.String key)
Returns true if thekey
corresponds to an OSM true value.- Parameters:
key
- OSM key- Returns:
true
if thekey
corresponds to an OSM true value- See Also:
OsmUtils.isTrue(String)
-
isKeyFalse
default boolean isKeyFalse(java.lang.String key)
Returns true if thekey
corresponds to an OSM false value.- Parameters:
key
- OSM key- Returns:
true
if thekey
corresponds to an OSM false value- See Also:
OsmUtils.isFalse(String)
-
ofTags
static Tagged ofTags(java.util.Collection<Tag> tags)
Returns a Tagged instance for the given tag collection- Parameters:
tags
- the tag collection- Returns:
- a Tagged instance for the given tag collection
-
-