ecologylab.xml
Class ClassDescriptor<ES extends ElementState>

java.lang.Object
  extended by ecologylab.generic.Debug
      extended by ecologylab.xml.ElementState
          extended by ecologylab.xml.ClassDescriptor<ES>
All Implemented Interfaces:
FieldTypes, Mappable<java.lang.String>, XMLTranslationExceptionTypes

public class ClassDescriptor<ES extends ElementState>
extends ElementState
implements FieldTypes, Mappable<java.lang.String>

Cached object that holds all of the structures needed to optimize translations to and from XML for a single subclass of ElementState. A rootOptimizationsMap keeps track of these, using the XML tag as the key.

This structure itself, as well as the structure within it, are created just in time, by lazy evaluation.

Author:
andruid

Nested Class Summary
 
Nested classes/interfaces inherited from class ecologylab.xml.ElementState
ElementState.DeclarationStyle, ElementState.xml_attribute, ElementState.xml_bind_from, ElementState.xml_bind_to, ElementState.xml_class, ElementState.xml_classes, ElementState.xml_collection, ElementState.xml_format, ElementState.xml_leaf, ElementState.xml_map, ElementState.xml_nested, ElementState.xml_nowrap, ElementState.xml_other_tags, ElementState.xml_scope, ElementState.xml_tag, ElementState.xml_text
 
Field Summary
 
Fields inherited from class ecologylab.xml.ElementState
CDATA, NORMAL, UTF16, UTF16_LE, UTF8
 
Fields inherited from interface ecologylab.xml.FieldTypes
ATTRIBUTE, AWFUL_OLD_NESTED_ELEMENT, BAD_FIELD, COLLECTION_ELEMENT, COLLECTION_SCALAR, IGNORED_ATTRIBUTE, IGNORED_ELEMENT, LEAF, MAP_ELEMENT, MAP_SCALAR, NAME_SPACE_ATTRIBUTE, NAME_SPACE_LEAF_NODE, NAME_SPACE_MASK, NAME_SPACE_NESTED_ELEMENT, NAMESPACE_IGNORED_ELEMENT, NAMESPACE_TRIAL_ELEMENT, NESTED_ELEMENT, PSEUDO_FIELD_DESCRIPTOR, ROOT, TEXT_ELEMENT, TEXT_NODE_VALUE, UNSET_TYPE, WRAPPER, XMLNS_ATTRIBUTE, XMLNS_IGNORED
 
Fields inherited from interface ecologylab.xml.XMLTranslationExceptionTypes
FILE_NOT_FOUND, IO_EXCEPTION, NULL_PURL, UNKNOWN
 
Constructor Summary
ClassDescriptor()
          Default constructor only for use by translateFromXML().
 
Method Summary
 java.util.ArrayList<FieldDescriptor> attributeFieldDescriptors()
           
 java.lang.Class<ES> describedClass()
           
 java.util.ArrayList<FieldDescriptor> elementFieldOptimizations()
           
static ClassDescriptor getClassDescriptor(java.lang.Class<? extends ElementState> thatClass)
          Obtain Optimizations object in the global scope of root Optimizations.
static ClassDescriptor getClassDescriptor(ElementState elementState)
          Obtain Optimizations object in the global scope of root Optimizations.
 java.lang.String getDecribedClassSimpleName()
           
 java.lang.Class<ES> getDescribedClass()
           
 java.lang.String getDescribedClassPackageName()
           
 FieldDescriptor getFieldDescriptorByTag(java.lang.String tag, TranslationScope tScope, ElementState context)
           
static
<T extends FieldDescriptor>
HashMapArrayList<java.lang.String,FieldDescriptor>
getFieldDescriptors(java.lang.Class<? extends ElementState> thatClass, java.lang.Class<T> fieldDescriptorClass)
          Construct a set of FieldDescriptor objects for the class.
 HashMapArrayList<java.lang.String,FieldDescriptor> getFieldDescriptorsByFieldName()
           
 ES getInstance()
           
 java.lang.String getSuperClassName()
           
 java.lang.String getTagName()
           
static HashMapArrayList<java.lang.String,FieldDescriptor> getTheFieldDescriptors(java.lang.Class<? extends ElementState> thatClass)
          Construct a set of FieldDescriptor objects for the class.
 boolean hasScalarTextField()
           
 boolean isEmpty()
           
 java.lang.String key()
          The tagName.
static void main(java.lang.String[] s)
           
 int numFields()
           
 FieldDescriptor pseudoFieldDescriptor()
          Form a pseudo-FieldDescriptor-object for a root element.
 java.lang.String toString()
           
 
Methods inherited from class ecologylab.xml.ElementState
buildDOM, buildDOM, buildDOM, buildDOM, buildDOM, buildDOMFromXMLCharSequence, buildDOMFromXMLString, checkAnnotation, classDescriptor, createParentDirs, getChildFieldAccessors, getElementStateById, getFieldDescriptors, getNestedNameSpace, getTextNodeString, lookupNestedNameSpace, parent, recycle, setDeclarationStyle, 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, warning, warning, weird, weird
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassDescriptor

public ClassDescriptor()
Default constructor only for use by translateFromXML().

Method Detail

getTagName

public java.lang.String getTagName()

getClassDescriptor

public static ClassDescriptor getClassDescriptor(ElementState elementState)
Obtain Optimizations object in the global scope of root Optimizations. Uses just-in-time / lazy evaluation. The first time this is called for a given ElementState class, it constructs a new Optimizations saves it in our rootOptimizationsMap, and returns it.

Subsequent calls merely pass back the already created object from the rootOptimizationsMap.

Parameters:
elementState - An ElementState object that we're looking up Optimizations for.
Returns:

getClassDescriptor

public static ClassDescriptor getClassDescriptor(java.lang.Class<? extends ElementState> thatClass)
Obtain Optimizations object in the global scope of root Optimizations. Uses just-in-time / lazy evaluation. The first time this is called for a given ElementState class, it constructs a new Optimizations saves it in our rootOptimizationsMap, and returns it.

Subsequent calls merely pass back the already created object from the rootOptimizationsMap.

Parameters:
thatClass -
Returns:

pseudoFieldDescriptor

public FieldDescriptor pseudoFieldDescriptor()
Form a pseudo-FieldDescriptor-object for a root element. We say pseudo, because there is no Field corresponding to this element. The pseudo-FieldDescriptor-object still guides the translation process.

Returns:

attributeFieldDescriptors

public java.util.ArrayList<FieldDescriptor> attributeFieldDescriptors()

elementFieldOptimizations

public java.util.ArrayList<FieldDescriptor> elementFieldOptimizations()

getFieldDescriptorByTag

public FieldDescriptor getFieldDescriptorByTag(java.lang.String tag,
                                               TranslationScope tScope,
                                               ElementState context)

getTheFieldDescriptors

public static HashMapArrayList<java.lang.String,FieldDescriptor> getTheFieldDescriptors(java.lang.Class<? extends ElementState> thatClass)
Construct a set of FieldDescriptor objects for the class.

Parameters:
thatClass -
Returns:

getFieldDescriptors

public static <T extends FieldDescriptor> HashMapArrayList<java.lang.String,FieldDescriptor> getFieldDescriptors(java.lang.Class<? extends ElementState> thatClass,
                                                                                                                 java.lang.Class<T> fieldDescriptorClass)
Construct a set of FieldDescriptor objects for the class.

Type Parameters:
T -
Parameters:
thatClass -
fieldDescriptorClass - Subclass of FieldDescriptor to use to construct.
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class Debug

describedClass

public java.lang.Class<ES> describedClass()
Returns:
the Class Object that this describes.

hasScalarTextField

public boolean hasScalarTextField()
Overrides:
hasScalarTextField in class ElementState

getDescribedClass

public java.lang.Class<ES> getDescribedClass()

isEmpty

public boolean isEmpty()
Returns:
true if this is an empty entry, for a tag that we do not parse. No class is associated with such an entry.

getDecribedClassSimpleName

public java.lang.String getDecribedClassSimpleName()

getDescribedClassPackageName

public java.lang.String getDescribedClassPackageName()

getInstance

public ES getInstance()
                                    throws XMLTranslationException
Throws:
XMLTranslationException

numFields

public int numFields()

key

public java.lang.String key()
The tagName.

Specified by:
key in interface Mappable<java.lang.String>

getFieldDescriptorsByFieldName

public HashMapArrayList<java.lang.String,FieldDescriptor> getFieldDescriptorsByFieldName()

getSuperClassName

public java.lang.String getSuperClassName()

main

public static void main(java.lang.String[] s)