gate.util
Class OptionsMap

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.TreeMap<Object,Object>
          extended by gate.util.OptionsMap
All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>, NavigableMap<Object,Object>, SortedMap<Object,Object>

public class OptionsMap
extends TreeMap<Object,Object>

A map that stores values as strings and provides support for converting some frequently used types to and from string.
Not very efficient as there is a lot of conversions from/to String. The conversion could happen only when loading/saving from/to a file.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
OptionsMap()
           
 
Method Summary
 Boolean getBoolean(Object key)
          If the object stored under key is a Boolean then returns its value otherwise returns false.
 Double getDouble(Object key)
          If the object stored under key is an Double then returns its value otherwise returns null.
 Font getFont(Object key)
          If the object stored under key is a Font then returns its value otherwise returns null.
 Integer getInt(Object key)
          If the object stored under key is an Integer then returns its value otherwise returns null.
 Map<String,String> getMap(Object key)
          If the object stored under key is a map then returns its value otherwise returns an empty map.
 LinkedHashSet<String> getSet(Object key)
          If the object stored under key is a set then returns its value otherwise returns an empty set.
 String getString(Object key)
          If the object stored under key is a String then returns its value otherwise returns null.
 Object put(Object key, LinkedHashSet<String> value)
           
 Object put(Object key, Map<String,String> value)
           
 Object put(Object key, Object value)
          Converts the value to string using Strings.toString(Object) method and then stores it.
 
Methods inherited from class java.util.TreeMap
ceilingEntry, ceilingKey, clear, clone, comparator, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, get, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, navigableKeySet, pollFirstEntry, pollLastEntry, putAll, remove, size, subMap, subMap, tailMap, tailMap, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, isEmpty, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode, isEmpty
 

Constructor Detail

OptionsMap

public OptionsMap()
Method Detail

put

public Object put(Object key,
                  Object value)
Converts the value to string using Strings.toString(Object) method and then stores it. There is get methods for values that are a String, an Integer, a Boolean, a Font, a List of String and a Map of String*String.

Specified by:
put in interface Map<Object,Object>
Overrides:
put in class TreeMap<Object,Object>

put

public Object put(Object key,
                  LinkedHashSet<String> value)

put

public Object put(Object key,
                  Map<String,String> value)

getInt

public Integer getInt(Object key)
If the object stored under key is an Integer then returns its value otherwise returns null.

Parameters:
key - key associated to the value to retrieve
Returns:
the associated integer

getDouble

public Double getDouble(Object key)
If the object stored under key is an Double then returns its value otherwise returns null.

Parameters:
key - key associated to the value to retrieve
Returns:
the associated Double

getBoolean

public Boolean getBoolean(Object key)
If the object stored under key is a Boolean then returns its value otherwise returns false.

Parameters:
key - key associated to the value to retrieve
Returns:
the associated boolean

getString

public String getString(Object key)
If the object stored under key is a String then returns its value otherwise returns null.

Parameters:
key - key associated to the value to retrieve
Returns:
the associated string

getFont

public Font getFont(Object key)
If the object stored under key is a Font then returns its value otherwise returns null.

Parameters:
key - key associated to the value to retrieve
Returns:
the associated font

getSet

public LinkedHashSet<String> getSet(Object key)
If the object stored under key is a set then returns its value otherwise returns an empty set.

Parameters:
key - key associated to the value to retrieve
Returns:
the associated linked hash set

getMap

public Map<String,String> getMap(Object key)
If the object stored under key is a map then returns its value otherwise returns an empty map.

Parameters:
key - key associated to the value to retrieve
Returns:
the associated map