ecologylab.xml.types.element
Class SynchronizedHashMapState<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.SynchronizedHashMapState<K,V>
All Implemented Interfaces:
OptimizationTypes, XMLTranslationExceptionTypes, java.lang.Cloneable, java.util.Map<K,V>

public class SynchronizedHashMapState<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). The underlying map object is synchronized.

Author:
andruid, Zachary O. Toups (toupsz@cs.tamu.edu)

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
 
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
SynchronizedHashMapState()
           
 
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.Map<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)
           
 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, recycle, 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
 

Constructor Detail

SynchronizedHashMapState

public SynchronizedHashMapState()
Method Detail

map

protected java.util.Map<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>>