Class SaajStaxWriter.DeferredElement

  • Enclosing class:
    SaajStaxWriter

    public static class SaajStaxWriter.DeferredElement
    extends Object
    Holds details of element that needs to be deferred in order to manage namespace assignments correctly.

    An instance of can be set with all the aspects of the element name (local name, prefix, namespace uri). Attributes and namespace declarations (special case of attribute) can be added. Namespace declarations are handled so that the element namespace is updated if it is implied by the namespace declaration and the namespace was not set to non-null value previously.

    The state of this object can be flushed to SOAPElement - new SOAPElement will be added a child element; the new element will have exactly the shape as represented by the state of this object. Note that the flushTo(SOAPElement) method does nothing (and returns the argument immediately) if the state of this object is not initialized (i.e. local name is null).

    Author:
    [email protected]
    • Method Detail

      • setPrefix

        public void setPrefix​(String prefix)
        Set prefix of the element.
        Parameters:
        prefix - namespace prefix
      • setLocalName

        public void setLocalName​(String localName)
        Set local name of the element.

        This method initializes the element.

        Parameters:
        localName - local name not null
      • setNamespaceUri

        public void setNamespaceUri​(String namespaceUri)
        Set namespace uri.
        Parameters:
        namespaceUri - namespace uri
      • addNamespaceDeclaration

        public void addNamespaceDeclaration​(String prefix,
                                            String namespaceUri)
        Adds namespace prefix assignment to the element.
        Parameters:
        prefix - prefix (not null)
        namespaceUri - namespace uri
      • addAttribute

        public void addAttribute​(String prefix,
                                 String ns,
                                 String ln,
                                 String value)
        Adds attribute to the element.
        Parameters:
        prefix - prefix
        ns - namespace
        ln - local name
        value - value
      • flushTo

        public jakarta.xml.soap.SOAPElement flushTo​(jakarta.xml.soap.SOAPElement target)
                                             throws XMLStreamException
        Flushes state of this element to the target element.

        If this element is initialized then it is added with all the namespace declarations and attributes to the target element as a child. The state of this element is reset to uninitialized. The newly added element object is returned.

        If this element is not initialized then the target is returned immediately, nothing else is done.

        Parameters:
        target - target element
        Returns:
        target or new element
        Throws:
        XMLStreamException - on error
      • isInitialized

        public boolean isInitialized()
        Is the element initialized?
        Returns:
        boolean indicating whether it was initialized after last flush