Class XmlContext
java.lang.Object
net.officefloor.plugin.xml.marshall.tree.XmlContext
Context for XML marhalling of source object.
- Author:
- Daniel Sagenschneider
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<String,XmlContext> ChildXmlContextinstances of thisXmlContext.protected final XmlMappingMetaData[]Configuration for the specific configuration.protected final Map<Class<?>,XmlSpecificContext> Mapping of concrete class to specific context instance to handling mappings.protected final StringName of the element.protected final ReferencedXmlMappingRegistryRegistry ofXmlMappingthat may be referenced.protected final TranslatorRegistryRegistry ofTranslatorinstances. -
Constructor Summary
ConstructorsConstructorDescriptionXmlContext(Class<?> upperType, String elementName, XmlMappingMetaData[] configuration, boolean isCreateSpecificType, TranslatorRegistry translatorRegistry, ReferencedXmlMappingRegistry referenceRegistry) Initiate theXmlContextfrom configuration. -
Method Summary
Modifier and TypeMethodDescriptiongetChildContext(String reference) Obtains the childXmlContextregistered under the reference.getSpecificContext(Class<?> specificType) Obtains theXmlSpecificContextspecific to the input type.voidMarshalls the source object as XML to the output.voidregisterChildContext(String reference, XmlContext childContext) Registers a childXmlContextof thisXmlContext.
-
Field Details
-
elementName
Name of the element. -
contexts
Mapping of concrete class to specific context instance to handling mappings. -
translatorRegistry
Registry ofTranslatorinstances. -
referenceRegistry
Registry ofXmlMappingthat may be referenced. -
configuration
Configuration for the specific configuration. -
childContexts
ChildXmlContextinstances of thisXmlContext. Lazy loaded as may not always have children.
-
-
Constructor Details
-
XmlContext
public XmlContext(Class<?> upperType, String elementName, XmlMappingMetaData[] configuration, boolean isCreateSpecificType, TranslatorRegistry translatorRegistry, ReferencedXmlMappingRegistry referenceRegistry) throws XmlMarshallException Initiate 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 Details
-
getSpecificContext
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
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
Obtains the childXmlContextregistered under the reference.- Parameters:
reference- Reference to identify the childXmlContext.- Returns:
- Child
XmlContextornullif no childXmlContextby reference.
-
registerChildContext
Registers a childXmlContextof thisXmlContext.- Parameters:
reference- Reference to identify the childXmlContext.childContext- ChildXmlContextto register.
-