ecologylab.xml.types.element
Class HashMapState<K,V extends ElementState & Mappable<K>>

java.lang.Object
  extended by ecologylab.generic.Debug
      extended by ecologylab.xml.ElementState
          extended by ecologylab.xml.types.element.HashMapState<K,V>
All Implemented Interfaces:
OptimizationTypes, XMLTranslationExceptionTypes, java.lang.Cloneable, java.util.Map<K,V>
Direct Known Subclasses:
PrefSet

public class HashMapState<K,V extends ElementState & Mappable<K>>
extends ElementState
implements java.lang.Cloneable, java.util.Map<K,V>

An ElementState XML tree node that supports a HashMap whose values are Mappable (capable of supplying their own key into the map).

Author:
andruid

Nested Class Summary
 
Nested classes/interfaces inherited from class ecologylab.xml.ElementState
ElementState.ClassToCollectionMap, ElementState.DeclarationStyle, ElementState.xml_attribute, ElementState.xml_class, ElementState.xml_classes, ElementState.xml_collection, ElementState.xml_leaf, ElementState.xml_map, ElementState.xml_nested, ElementState.xml_tag
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
protected  java.util.HashMap<K,V> map
          Stores the actual mappings.
 
Fields inherited from class ecologylab.xml.ElementState
CDATA, ESTIMATE_CHARS_PER_FIELD, FLOATING_PRECISION_OFF, MARSHALLING_PARAMS, NORMAL, UTF16, UTF16_LE, UTF8, XML_FILE_HEADER
 
Fields inherited from interface ecologylab.xml.OptimizationTypes
BAD_FIELD, COLLECTION_ELEMENT, COLLECTION_SCALAR, IGNORED_ATTRIBUTE, IGNORED_ELEMENT, LEAF_NODE_VALUE, MAP_ELEMENT, MAP_SCALAR, NAME_SPACE_ATTRIBUTE, NAME_SPACE_LEAF_NODE, NAME_SPACE_MASK, NAME_SPACE_NESTED_ELEMENT, NAMESPACE_IGNORED_ELEMENT, NAMESPACE_TRIAL_ELEMENT, OTHER_NESTED_ELEMENT, REGULAR_ATTRIBUTE, REGULAR_NESTED_ELEMENT, ROOT, UNSET_TYPE, XMLNS_ATTRIBUTE, XMLNS_IGNORED
 
Fields inherited from interface ecologylab.xml.XMLTranslationExceptionTypes
FILE_NOT_FOUND, IO_EXCEPTION, NULL_PURL, UNKNOWN
 
Constructor Summary
HashMapState()
           
 
Method Summary
 V add(V value)
          Convienence method for adding Mappable elements.
 void clear()
           
protected  java.lang.Object clone()
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set<java.util.Map.Entry<K,V>> entrySet()
           
 V get(java.lang.Object key)
           
protected  java.util.Map getMap(java.lang.Class thatClass)
          When translating from XML, if a tag is encountered with no matching field, perhaps it belongs in a Collection.
 boolean isEmpty()
           
 java.util.Set<K> keySet()
           
protected  java.util.HashMap<K,V> map()
          Use lazy evaluation for creating the map, in order to make it possible this class lightweight enough to use in subclass situations where they may be no elements added to the set, where the ElementState is only being used for direct fields.
 V put(K key, V value)
           
 void putAll(java.util.Map<? extends K,? extends V> t)
           
 void recycle()
          Clear data structures and references to enable garbage collecting of resources associated with this.
 V remove(java.lang.Object key)
           
 int size()
           
 java.util.Collection<V> values()
           
 
Methods inherited from class ecologylab.xml.ElementState
addNestedElement, addNestedElement, appendTextNodeString, buildDOM, buildDOM, buildDOM, buildDOM, buildDOM, buildDOMFromXMLCharSequence, buildDOMFromXMLString, checkAnnotation, convertNameStyles, createChildHook, fieldToXMLOptimizations, floatingPrecision, getCollection, getElementStateById, getNestedNameSpace, getTextNodeString, leafElementFieldNames, lookupNestedNameSpace, optimizations, parent, postTranslationProcessingHook, preTranslationProcessingHook, setDeclarationStyle, setFieldUsingTypeRegistry, setFloatingPrecision, setParent, setUseDOMForTranslateTo, translateFromXML, translateFromXML, translateFromXML, translateFromXML, translateFromXML, translateFromXMLCharSequence, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOMCharSequence, translateFromXMLDOMCharSequence, translateFromXMLRootNode, translateFromXMLSAX, translateFromXMLSAX, translateFromXMLSAX, translateFromXMLSAX, translateFromXMLSAX, translateToDOM, translateToXML, translateToXML, translateToXML, translateToXML, writePrettyXML, writePrettyXML, writePrettyXML
 
Methods inherited from class ecologylab.generic.Debug
classSimpleName, closeLoggingFile, debug, debug, debug, debug, debugA, debugA, debugA, debugI, debugI, debugI, error, error, getClassName, getClassName, getInteractive, getPackageName, getPackageName, getPackageName, initialize, level, level, level, logToFile, print, print, println, println, println, println, println, println, printlnA, printlnA, printlnA, printlnI, printlnI, printlnI, printlnI, setLoggingFile, show, show, superString, toggleInteractive, toString, toString, warning, warning, weird, weird
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

map

protected java.util.HashMap<K,V extends ElementState & Mappable<K>> map
Stores the actual mappings.

Constructor Detail

HashMapState

public HashMapState()
Method Detail

map

protected java.util.HashMap<K,V> map()
Use lazy evaluation for creating the map, in order to make it possible this class lightweight enough to use in subclass situations where they may be no elements added to the set, where the ElementState is only being used for direct fields.

Returns:

getMap

protected java.util.Map getMap(java.lang.Class thatClass)
Description copied from class: ElementState
When translating from XML, if a tag is encountered with no matching field, perhaps it belongs in a Collection. This method tells us which collection object that would be.

Overrides:
getMap in class ElementState
Parameters:
thatClass - The class of the ElementState superclass that could be stored in a Collection.
Returns:

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

add

public V add(V value)
Convienence method for adding Mappable elements. This method simply calls put(value.key(), value).

Parameters:
value -

clear

public void clear()
Specified by:
clear in interface java.util.Map<K,V extends ElementState & Mappable<K>>

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map<K,V extends ElementState & Mappable<K>>

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map<K,V extends ElementState & Mappable<K>>

entrySet

public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface java.util.Map<K,V extends ElementState & Mappable<K>>

get

public V get(java.lang.Object key)
Specified by:
get in interface java.util.Map<K,V extends ElementState & Mappable<K>>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map<K,V extends ElementState & Mappable<K>>

keySet

public java.util.Set<K> keySet()
Specified by:
keySet in interface java.util.Map<K,V extends ElementState & Mappable<K>>

put

public V put(K key,
             V value)
Specified by:
put in interface java.util.Map<K,V extends ElementState & Mappable<K>>

putAll

public void putAll(java.util.Map<? extends K,? extends V> t)
Specified by:
putAll in interface java.util.Map<K,V extends ElementState & Mappable<K>>

remove

public V remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map<K,V extends ElementState & Mappable<K>>

size

public int size()
Specified by:
size in interface java.util.Map<K,V extends ElementState & Mappable<K>>

values

public java.util.Collection<V> values()
Specified by:
values in interface java.util.Map<K,V extends ElementState & Mappable<K>>

recycle

public void recycle()
Clear data structures and references to enable garbage collecting of resources associated with this. Calling recycle() on an HashMapState has the side effect of recycling every value contained in the HashMapState. If the values of the HashMapState should be retained, then call clear(), then recycle().

Overrides:
recycle in class ElementState