Class XmlContext
- java.lang.Object
-
- net.officefloor.plugin.xml.marshall.tree.XmlContext
-
public class XmlContext extends java.lang.Object
Context 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>
childContexts
ChildXmlContext
instances of thisXmlContext
.protected XmlMappingMetaData[]
configuration
Configuration for the specific configuration.protected java.util.Map<java.lang.Class<?>,XmlSpecificContext>
contexts
Mapping of concrete class to specific context instance to handling mappings.protected java.lang.String
elementName
Name of the element.protected ReferencedXmlMappingRegistry
referenceRegistry
Registry ofXmlMapping
that may be referenced.protected TranslatorRegistry
translatorRegistry
Registry ofTranslator
instances.
-
Constructor Summary
Constructors Constructor Description XmlContext(java.lang.Class<?> upperType, java.lang.String elementName, XmlMappingMetaData[] configuration, boolean isCreateSpecificType, TranslatorRegistry translatorRegistry, ReferencedXmlMappingRegistry referenceRegistry)
Initiate theXmlContext
from configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description XmlContext
getChildContext(java.lang.String reference)
Obtains the childXmlContext
registered under the reference.XmlSpecificContext
getSpecificContext(java.lang.Class<?> specificType)
Obtains theXmlSpecificContext
specific to the input type.void
marshall(java.lang.Object source, XmlOutput output)
Marshalls the source object as XML to the output.void
registerChildContext(java.lang.String reference, XmlContext childContext)
Registers a childXmlContext
of 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 ofTranslator
instances.
-
referenceRegistry
protected final ReferencedXmlMappingRegistry referenceRegistry
Registry ofXmlMapping
that may be referenced.
-
configuration
protected final XmlMappingMetaData[] configuration
Configuration for the specific configuration.
-
childContexts
protected java.util.Map<java.lang.String,XmlContext> childContexts
ChildXmlContext
instances 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 XmlMarshallException
Initiate theXmlContext
from 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 ofTranslator
instances for translating objects to string values.referenceRegistry
- Registry ofXmlMapping
that may be referenced.- Throws:
XmlMarshallException
- Should thisXmlContext
fail to configure.
-
-
Method Detail
-
getSpecificContext
public XmlSpecificContext getSpecificContext(java.lang.Class<?> specificType) throws XmlMarshallException
Obtains theXmlSpecificContext
specific to the input type.- Parameters:
specificType
- Specific type to obtain theXmlSpecificContext
for.- Returns:
XmlSpecificContext
for the input type.- Throws:
XmlMarshallException
- If fails to obtain theXmlSpecificContext
.
-
marshall
public void marshall(java.lang.Object source, XmlOutput output) throws XmlMarshallException
Marshalls 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 childXmlContext
registered under the reference.- Parameters:
reference
- Reference to identify the childXmlContext
.- Returns:
- Child
XmlContext
ornull
if no childXmlContext
by reference.
-
registerChildContext
public void registerChildContext(java.lang.String reference, XmlContext childContext)
Registers a childXmlContext
of thisXmlContext
.- Parameters:
reference
- Reference to identify the childXmlContext
.childContext
- ChildXmlContext
to register.
-
-