Class XmlSpecificContext


  • public class XmlSpecificContext
    extends java.lang.Object
    Instance of XmlContext for a particular concrete class.
    Author:
    Daniel Sagenschneider
    • Field Detail

      • mappings

        protected final java.util.List<XmlMapping> mappings
        Mappings to be applied for this context.
    • Constructor Detail

      • XmlSpecificContext

        public XmlSpecificContext​(java.lang.Class<?> upperBoundType,
                                  java.lang.String contextElementName,
                                  XmlMappingMetaData[] configuration,
                                  XmlContext context,
                                  TranslatorRegistry translatorRegistry,
                                  ReferencedXmlMappingRegistry referenceRegistry)
                           throws XmlMarshallException
        Initiate context from the upper bound type of the object.
        Parameters:
        upperBoundType - Upper bound type of the source object.
        contextElementName - Name of element or null if not output element for context.
        configuration - Configuration of the context.
        context - Generic context to load child contexts.
        translatorRegistry - Registry of Translator to translate values.
        referenceRegistry - Registry of XmlMapping that may be referenced.
        Throws:
        XmlMarshallException - If fails to configure this context.
      • XmlSpecificContext

        public XmlSpecificContext​(java.lang.Object source,
                                  java.lang.Class<?> sourceType,
                                  java.lang.String elementName,
                                  XmlMappingMetaData[] configuration,
                                  XmlContext context,
                                  TranslatorRegistry translatorRegistry,
                                  ReferencedXmlMappingRegistry referenceRegistry)
                           throws XmlMarshallException
        Initiate context to specific concrete implementation of the object.
        Parameters:
        source - The first instance of the object.
        sourceType - Class of the object.
        elementName - Name of element or null if not output element for context.
        configuration - Configuration of the context.
        context - Generic context to obtain child contexts.
        translatorRegistry - Registry of Translator instances.
        referenceRegistry - Registry XmlMapping that may be referenced.
        Throws:
        XmlMarshallException - If fails to configure this context.
    • Method Detail

      • marshall

        public void marshall​(java.lang.Object source,
                             XmlOutput output)
                      throws XmlMarshallException
        Does the marshalling of the source object to the output.
        Parameters:
        source - Source object to marshall.
        output - Output to send XML.
        Throws:
        XmlMarshallException - If fails to marshall source object.
      • loadAttributes

        protected void loadAttributes​(java.lang.Class<?> upperBoundType,
                                      XmlMappingMetaData[] attributes,
                                      TranslatorRegistry translatorRegistry)
                               throws XmlMarshallException
        Loads the attribute mappings for this context.
        Parameters:
        upperBoundType - Upper bound type of the source object.
        attributes - Configuration of the attributes.
        translatorRegistry - Registry of Translator instances.
        Throws:
        XmlMarshallException - If fails to load attribute mappings.
      • addXmlMapping

        protected void addXmlMapping​(XmlMapping mapping)
        Adds a XmlMapping to the listing of XmlMapping instances for this context.
        Parameters:
        mapping - XmlMapping to add as next mapping.