terp - the Codemesh Modular
Template Interpreter v1.3.337

com.codemesh.terp.util
Class CaseInsensitiveTreeMap<T>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.TreeMap<java.lang.String,T>
          extended by com.codemesh.terp.util.CaseInsensitiveTreeMap<T>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,T>, java.util.NavigableMap<java.lang.String,T>, java.util.SortedMap<java.lang.String,T>

public class CaseInsensitiveTreeMap<T>
extends java.util.TreeMap<java.lang.String,T>

A map that registers entries under their real name but creates lowercase aliases for them as well. This map will have the following behavior: - keys that differ in case can be distinguished if looked up using their exactly cased name. - keys that differ in case cannot be distinguished if looked up with a key that is not correctly cased. Iteration over the keys will be in case sensitive order because trying to make the underlying map case insensitive will change the put/get behavior.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
CaseInsensitiveTreeMap()
           
CaseInsensitiveTreeMap(java.util.Comparator<java.lang.String> comparator)
           
CaseInsensitiveTreeMap(java.util.Map<java.lang.String,T> m)
           
CaseInsensitiveTreeMap(java.util.SortedMap<java.lang.String,T> m)
           
 
Method Summary
 void addAlias(java.lang.String alias, java.lang.String key)
          Adds a name alias to the map.
 boolean containsKey(java.lang.Object okey)
           
 java.util.Map<java.lang.String,T> filteredMap(Selector<T>... selectors)
          Returns a filtered map whose entries are backed by this map but consist only of those that satisfy at least one of the selector criteria that are provided.
 T get(java.lang.Object okey)
           
 java.lang.Object getFromNumber(java.lang.Number number)
          Returns an object from the map based on a numeric key.
 T put(java.lang.String key, T value)
           
 void putAll(java.util.Map<? extends java.lang.String,? extends T> map)
           
 void removeAlias(java.lang.String alias)
          Removes a name alias from the map.
 void setFromNumber(java.lang.Number number, T value)
           
 
Methods inherited from class java.util.TreeMap
ceilingEntry, ceilingKey, clear, clone, comparator, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, navigableKeySet, pollFirstEntry, pollLastEntry, 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

CaseInsensitiveTreeMap

public CaseInsensitiveTreeMap()

CaseInsensitiveTreeMap

public CaseInsensitiveTreeMap(java.util.Comparator<java.lang.String> comparator)

CaseInsensitiveTreeMap

public CaseInsensitiveTreeMap(java.util.Map<java.lang.String,T> m)

CaseInsensitiveTreeMap

public CaseInsensitiveTreeMap(java.util.SortedMap<java.lang.String,T> m)
Method Detail

putAll

public void putAll(java.util.Map<? extends java.lang.String,? extends T> map)
Specified by:
putAll in interface java.util.Map<java.lang.String,T>
Overrides:
putAll in class java.util.TreeMap<java.lang.String,T>

put

public T put(java.lang.String key,
             T value)
Specified by:
put in interface java.util.Map<java.lang.String,T>
Overrides:
put in class java.util.TreeMap<java.lang.String,T>

get

public T get(java.lang.Object okey)
Specified by:
get in interface java.util.Map<java.lang.String,T>
Overrides:
get in class java.util.TreeMap<java.lang.String,T>

containsKey

public boolean containsKey(java.lang.Object okey)
Specified by:
containsKey in interface java.util.Map<java.lang.String,T>
Overrides:
containsKey in class java.util.TreeMap<java.lang.String,T>

getFromNumber

public java.lang.Object getFromNumber(java.lang.Number number)
Returns an object from the map based on a numeric key. The numeric key is interpreted as an index by default, but the implementation could be overridden for other purposes.

Don't use this function to iterate over the map because its performance would be pretty horrible. It is intended to provide an entrypoint for integer properties like 'msvc.2005.compiler' where the integer is a version number and represents an attribute test rather than an index.

Parameters:
number - a number.
Returns:
an object or null.

setFromNumber

public void setFromNumber(java.lang.Number number,
                          T value)

addAlias

public void addAlias(java.lang.String alias,
                     java.lang.String key)
Adds a name alias to the map. The alias can be used to reference the same value that would be referenced by the key.

Parameters:
alias - the alias for the key.
key - the key.

removeAlias

public void removeAlias(java.lang.String alias)
Removes a name alias from the map.

Parameters:
alias - the alias to be forgotten.

filteredMap

public java.util.Map<java.lang.String,T> filteredMap(Selector<T>... selectors)
Returns a filtered map whose entries are backed by this map but consist only of those that satisfy at least one of the selector criteria that are provided.

Parameters:
selectors - the selectors one of whose conditions must be met by an element to be a member of the filtered map.
Returns:
a submap of entries that satisfy at least one selector.

terp - the Codemesh Modular
Template Interpreter v1.3.337

Copyright © 2008-2016 by Codemesh, Inc. All Rights Reserved.