uk.me.parabola.mkgmap.reader.osm
Class Tags

java.lang.Object
  extended by uk.me.parabola.mkgmap.reader.osm.Tags
All Implemented Interfaces:
java.lang.Iterable<java.lang.String>

public class Tags
extends java.lang.Object
implements java.lang.Iterable<java.lang.String>

Store the tags that belong to an Element. Used to use a HashMap for this. We used to have a requirement to be able to add to the map during iteration over it but now the main reason to keep this class is that it is more memory efficient than a regular HashMap (hash maps are the main use of memory in the application), as it doesn't allocate a Map.Entry object for every tag. Performance of the whole application is unchanged compared with when a regular HashMap was used. It doesn't fully behave the same way that a map would.

Author:
Steve Ratcliffe

Constructor Summary
Tags()
           
 
Method Summary
 java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> entryIterator()
           
 java.lang.String get(java.lang.Object key)
           
 java.util.Map<java.lang.String,java.lang.String> getTagsWithPrefix(java.lang.String prefix, boolean removePrefix)
           
 java.util.Iterator<java.lang.String> iterator()
          Iterates over the tags in a special way that is used to look up in the rules.
 java.lang.String put(java.lang.String key, java.lang.String value)
           
 java.lang.String remove(java.lang.Object key)
           
 void removeAll()
           
 int size()
          Retrieves the number of tags.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Tags

public Tags()
Method Detail

get

public java.lang.String get(java.lang.Object key)

size

public int size()
Retrieves the number of tags.

Returns:
number of tags

put

public java.lang.String put(java.lang.String key,
                            java.lang.String value)

remove

public java.lang.String remove(java.lang.Object key)

iterator

public java.util.Iterator<java.lang.String> iterator()
Iterates over the tags in a special way that is used to look up in the rules. If you have the tags a=b, c=d then you will get the following strings returned: "a=b", "a=*", "c=d", "c=*". If you add a tag during the iteration, then it is guaranteed to appear later in the iteration.

Specified by:
iterator in interface java.lang.Iterable<java.lang.String>

entryIterator

public java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> entryIterator()

getTagsWithPrefix

public java.util.Map<java.lang.String,java.lang.String> getTagsWithPrefix(java.lang.String prefix,
                                                                          boolean removePrefix)

removeAll

public void removeAll()