Class AbstractXMLObjectMarshaller

    • Field Detail

      • log

        @Nonnull
        private final org.slf4j.Logger log
        Class logger.
      • marshallerFactory

        @Nonnull
        private final MarshallerFactory marshallerFactory
        Factory for XMLObject Marshallers.
    • Constructor Detail

      • AbstractXMLObjectMarshaller

        protected AbstractXMLObjectMarshaller()
        Constructor.
    • Method Detail

      • marshall

        @Nonnull
        public Element marshall​(@Nonnull
                                XMLObject xmlObject)
                         throws MarshallingException
        Marshall this element, and its children, and root them in a newly created Document. The Document is created by a DocumentBuilder obtained from a DocumentBuilderFactory created without any additional parameters or properties set; that is the system defaults properties are used.
        Specified by:
        marshall in interface Marshaller
        Parameters:
        xmlObject - the object to marshall
        Returns:
        the W3C DOM element representing this SAML element
        Throws:
        MarshallingException - thrown if there is a problem marshalling the given object
      • marshall

        @Nonnull
        public Element marshall​(@Nonnull
                                XMLObject xmlObject,
                                @Nonnull
                                Document document)
                         throws MarshallingException
        Marshall this element, and its children, into a W3C DOM element. If the document does not have a Document Element the Element resulting from this marshalling will be set as the Document Element.
        Specified by:
        marshall in interface Marshaller
        Parameters:
        xmlObject - the object to marshall
        document - the DOM document the marshalled element will be placed in
        Returns:
        the W3C DOM element representing this XMLObject
        Throws:
        MarshallingException - thrown if there is a problem marshalling the given object
      • marshall

        @Nonnull
        public Element marshall​(@Nonnull
                                XMLObject xmlObject,
                                @Nonnull
                                Element parentElement)
                         throws MarshallingException
        Marshall the given XMLObject and append it as a child to the given parent element. NOTE: The given Element must be within a DOM tree whose root is the root of the Document owning the given Element.
        Specified by:
        marshall in interface Marshaller
        Parameters:
        xmlObject - the XMLObject to be marshalled
        parentElement - the parent of the Element resulting from marshalling the given XMLObject
        Returns:
        the marshalled XMLObject
        Throws:
        MarshallingException - thrown if the given XMLObject can not be marshalled.
      • setDocumentElement

        protected void setDocumentElement​(@Nonnull
                                          Document document,
                                          @Nonnull
                                          Element element)
        Sets the given element as the Document Element of the given Document. If the document already has a Document Element it is replaced by the given element.
        Parameters:
        document - the document
        element - the Element that will serve as the Document Element
      • marshallInto

        @Nonnull
        protected Element marshallInto​(@Nonnull
                                       XMLObject xmlObject,
                                       @Nonnull
                                       Element targetElement)
                                throws MarshallingException
        Marshalls the given XMLObject into the given DOM Element. The DOM Element must be within a DOM tree whose root is the Document Element of the Document that owns the given DOM Element.
        Parameters:
        xmlObject - the XMLObject to marshall
        targetElement - the Element into which the XMLObject is marshalled into
        Returns:
        the DOM element the XMLObject is marshalled into
        Throws:
        MarshallingException - thrown if there is a problem marshalling the object
      • marshallNamespacePrefix

        protected void marshallNamespacePrefix​(@Nonnull
                                               XMLObject xmlObject,
                                               @Nonnull
                                               Element domElement)
        Marshalls the namespace prefix of the XMLObject into the DOM element.
        Parameters:
        xmlObject - the XMLObject being marshalled
        domElement - the DOM element the XMLObject is being marshalled into
      • marshallChildElements

        protected void marshallChildElements​(@Nonnull
                                             XMLObject xmlObject,
                                             @Nonnull
                                             Element domElement)
                                      throws MarshallingException
        Marshalls the child elements of the given XMLObject.
        Parameters:
        xmlObject - the XMLObject whose children will be marshalled
        domElement - the DOM element that will recieved the marshalled children
        Throws:
        MarshallingException - thrown if there is a problem marshalling a child element
      • marshallNamespaces

        protected void marshallNamespaces​(@Nonnull
                                          XMLObject xmlObject,
                                          @Nonnull
                                          Element domElement)
        Creates the xmlns attributes for any namespaces set on the given XMLObject.
        Parameters:
        xmlObject - the XMLObject
        domElement - the DOM element the namespaces will be added to
      • marshallSchemaInstanceAttributes

        protected void marshallSchemaInstanceAttributes​(@Nonnull
                                                        XMLObject xmlObject,
                                                        @Nonnull
                                                        Element domElement)
                                                 throws MarshallingException
        Creates the XSI type, schemaLocation, and noNamespaceSchemaLocation attributes for an XMLObject.
        Parameters:
        xmlObject - the XMLObject
        domElement - the DOM element the namespaces will be added to
        Throws:
        MarshallingException - thrown if the schema type information is invalid
      • marshallAttributes

        protected void marshallAttributes​(@Nonnull
                                          XMLObject xmlObject,
                                          @Nonnull
                                          Element domElement)
                                   throws MarshallingException
        Marshalls a given XMLObject into a W3C Element. The given signing context should be blindly passed to the marshaller for child elements. The XMLObject passed to this method is guaranteed to be of the target name specified during this unmarshaller's construction. This default implementation of this method is a no-op
        Parameters:
        xmlObject - the XMLObject to marshall
        domElement - the W3C DOM element
        Throws:
        MarshallingException - thrown if there is a problem marshalling the element
      • marshallElementContent

        protected void marshallElementContent​(@Nonnull
                                              XMLObject xmlObject,
                                              @Nonnull
                                              Element domElement)
                                       throws MarshallingException
        Marshalls data from the XMLObject into content of the DOM Element. The default implementation of this method is a no-op.
        Parameters:
        xmlObject - the XMLObject
        domElement - the DOM element recieving the content
        Throws:
        MarshallingException - thrown if the textual content can not be added to the DOM element
      • prepareForAdoption

        private void prepareForAdoption​(@Nonnull
                                        XMLObject domCachingObject)
                                 throws MarshallingException
        Prepares the given DOM caching XMLObject for adoption into another document. If the XMLObject has a parent then all visible namespaces used by the given XMLObject and its descendants are declared within that subtree and the parent's DOM is invalidated.
        Parameters:
        domCachingObject - the XMLObject to prepare for adoption
        Throws:
        MarshallingException - thrown if a namespace within the XMLObject's DOM subtree can not be resolved.
      • marshallUnknownAttributes

        protected void marshallUnknownAttributes​(@Nonnull
                                                 AttributeExtensibleXMLObject xmlObject,
                                                 @Nonnull
                                                 Element domElement)
        Marshalls unknown attributes.
        Parameters:
        xmlObject - the Object which has the unknown attributes/
        domElement - where to marshall them to.