Package org.openstreetmap.josm.data.osm
Class TagMap
- All Implemented Interfaces:
Serializable,Map<String,String>
This class provides a read/write map that uses the same format as
AbstractPrimitive.keys.
It offers good performance for few keys.
It uses copy on write, so there cannot be a ConcurrentModificationException while iterating through it.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classAn iterator that iterates over the tags in this map.private static classThis is the entry set of this map.Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTagMap()Creates a new, empty tag map.Creates a new map using the given list of tags.Creates a new read only tag map using a key/value/key/value/...Create a new tag map and load it from the other map.Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()getTags()Gets a list of all tags contained in this map.(package private) String[]Gets the backing tags array.private static intindexOfKey(String[] tags, Object key) Finds a key in an array that is structured like thetagsarray and returns the position.intsize()toString()Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, isEmpty, keySet, putAll, valuesMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
serialVersionUID
- See Also:
-
EMPTY_TAGS
We use this array every time we want to represent an empty map. This saves us the burden of checking for null every time but saves some object allocations. -
tags
The tags field. This field is guarded using RCU.
-
-
Constructor Details
-
TagMap
public TagMap()Creates a new, empty tag map. -
TagMap
Create a new tag map and load it from the other map.- Parameters:
tags- The map to load from.- Since:
- 10604
-
TagMap
Copy constructor.- Parameters:
tagMap- The map to copy from.- Since:
- 10604
-
TagMap
Creates a new read only tag map using a key/value/key/value/... array.The array that is passed as parameter may not be modified after passing it to this map.
- Parameters:
tags- The tags array. It is not modified by this map.
-
TagMap
Creates a new map using the given list of tags. For duplicate keys the last value found is used.- Parameters:
tags- The tags- Since:
- 10736
-
-
Method Details
-
entrySet
-
containsKey
- Specified by:
containsKeyin interfaceMap<String,String> - Overrides:
containsKeyin classAbstractMap<String,String>
-
get
-
containsValue
- Specified by:
containsValuein interfaceMap<String,String> - Overrides:
containsValuein classAbstractMap<String,String>
-
put
-
remove
-
clear
-
size
-
getTags
Gets a list of all tags contained in this map.- Returns:
- The list of tags in the order they were added.
- Since:
- 10604
-
indexOfKey
Finds a key in an array that is structured like thetagsarray and returns the position.We allow the parameter to be passed to allow for better synchronization.
- Parameters:
tags- The tags array to search through.key- The key to search.- Returns:
- The index of the key (a multiple of two) or -1 if it was not found.
-
toString
- Overrides:
toStringin classAbstractMap<String,String>
-
getTagsArray
String[] getTagsArray()Gets the backing tags array. Do not modify this array.- Returns:
- The tags array.
-