Class XmlContext
- java.lang.Object
-
- net.officefloor.plugin.xml.marshall.tree.XmlContext
-
public class XmlContext extends java.lang.ObjectContext for XML marhalling of source object.- Author:
- Daniel Sagenschneider
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,XmlContext>childContextsChildXmlContextinstances of thisXmlContext.protected XmlMappingMetaData[]configurationConfiguration for the specific configuration.protected java.util.Map<java.lang.Class<?>,XmlSpecificContext>contextsMapping of concrete class to specific context instance to handling mappings.protected java.lang.StringelementNameName of the element.protected ReferencedXmlMappingRegistryreferenceRegistryRegistry ofXmlMappingthat may be referenced.protected TranslatorRegistrytranslatorRegistryRegistry ofTranslatorinstances.
-
Constructor Summary
Constructors Constructor Description XmlContext(java.lang.Class<?> upperType, java.lang.String elementName, XmlMappingMetaData[] configuration, boolean isCreateSpecificType, TranslatorRegistry translatorRegistry, ReferencedXmlMappingRegistry referenceRegistry)Initiate theXmlContextfrom configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description XmlContextgetChildContext(java.lang.String reference)Obtains the childXmlContextregistered under the reference.XmlSpecificContextgetSpecificContext(java.lang.Class<?> specificType)Obtains theXmlSpecificContextspecific to the input type.voidmarshall(java.lang.Object source, XmlOutput output)Marshalls the source object as XML to the output.voidregisterChildContext(java.lang.String reference, XmlContext childContext)Registers a childXmlContextof thisXmlContext.
-
-
-
Field Detail
-
elementName
protected final java.lang.String elementName
Name of the element.
-
contexts
protected final java.util.Map<java.lang.Class<?>,XmlSpecificContext> contexts
Mapping of concrete class to specific context instance to handling mappings.
-
translatorRegistry
protected final TranslatorRegistry translatorRegistry
Registry ofTranslatorinstances.
-
referenceRegistry
protected final ReferencedXmlMappingRegistry referenceRegistry
Registry ofXmlMappingthat may be referenced.
-
configuration
protected final XmlMappingMetaData[] configuration
Configuration for the specific configuration.
-
childContexts
protected java.util.Map<java.lang.String,XmlContext> childContexts
ChildXmlContextinstances of thisXmlContext. Lazy loaded as may not always have children.
-
-
Constructor Detail
-
XmlContext
public XmlContext(java.lang.Class<?> upperType, java.lang.String elementName, XmlMappingMetaData[] configuration, boolean isCreateSpecificType, TranslatorRegistry translatorRegistry, ReferencedXmlMappingRegistry referenceRegistry) throws XmlMarshallExceptionInitiate theXmlContextfrom configuration.- Parameters:
upperType- Upper bound on the type of the source object being marshalled.elementName- Name of XML element for wrapping the context.configuration- Configuration of thisXmlContext.isCreateSpecificType- Flags whether the initial specific type is created.translatorRegistry- Registry ofTranslatorinstances for translating objects to string values.referenceRegistry- Registry ofXmlMappingthat may be referenced.- Throws:
XmlMarshallException- Should thisXmlContextfail to configure.
-
-
Method Detail
-
getSpecificContext
public XmlSpecificContext getSpecificContext(java.lang.Class<?> specificType) throws XmlMarshallException
Obtains theXmlSpecificContextspecific to the input type.- Parameters:
specificType- Specific type to obtain theXmlSpecificContextfor.- Returns:
XmlSpecificContextfor the input type.- Throws:
XmlMarshallException- If fails to obtain theXmlSpecificContext.
-
marshall
public void marshall(java.lang.Object source, XmlOutput output) throws XmlMarshallExceptionMarshalls the source object as XML to the output.- Parameters:
source- Source object to marshall.output- Output to send marshalled XML.- Throws:
XmlMarshallException- If fails to marshall source object.
-
getChildContext
public XmlContext getChildContext(java.lang.String reference)
Obtains the childXmlContextregistered under the reference.- Parameters:
reference- Reference to identify the childXmlContext.- Returns:
- Child
XmlContextornullif no childXmlContextby reference.
-
registerChildContext
public void registerChildContext(java.lang.String reference, XmlContext childContext)Registers a childXmlContextof thisXmlContext.- Parameters:
reference- Reference to identify the childXmlContext.childContext- ChildXmlContextto register.
-
-