Class SimpleOutputElement

  • All Implemented Interfaces:
    javax.xml.namespace.NamespaceContext

    public final class SimpleOutputElement
    extends OutputElementBase
    Class that encapsulates information about a specific element in virtual output stack for namespace-aware writers. It provides support for URI-to-prefix mappings as well as namespace mapping generation.

    One noteworthy feature of the class is that it is designed to allow "short-term recycling", ie. instances can be reused within context of a simple document output. While reuse/recycling of such lightweight object is often useless or even counter productive, here it may be worth using, due to simplicity of the scheme (basically using a very simple free-elements linked list).

    • Field Detail

      • mParent

        protected SimpleOutputElement mParent
        Reference to the parent element, element enclosing this element. Null for root element. Non-final only to allow temporary pooling (on per-writer basis, to keep these short-lived).
      • mPrefix

        protected java.lang.String mPrefix
        Prefix that is used for the element. Can not be final, since sometimes it needs to be dynamically generated and bound after creating the element instance.
      • mLocalName

        protected java.lang.String mLocalName
        Local name of the element. Non-final only to allow reuse.
      • mURI

        protected java.lang.String mURI
        Namespace of the element, whatever mPrefix maps to. Non-final only to allow reuse.
      • mAttrSet

        protected java.util.HashSet<SimpleOutputElement.AttrName> mAttrSet
        Map used to check for duplicate attribute declarations, if feature is enabled.
    • Constructor Detail

      • SimpleOutputElement

        private SimpleOutputElement()
        Constructor for the virtual root element
      • SimpleOutputElement

        private SimpleOutputElement​(SimpleOutputElement parent,
                                    java.lang.String prefix,
                                    java.lang.String localName,
                                    java.lang.String uri,
                                    BijectiveNsMap ns)
    • Method Detail

      • relink

        private void relink​(SimpleOutputElement parent,
                            java.lang.String prefix,
                            java.lang.String localName,
                            java.lang.String uri)
        Method called to reuse a pooled instance.
      • createChild

        protected SimpleOutputElement createChild​(java.lang.String localName)
        Simplest factory method, which gets called when a 1-argument element output method is called. It is, then, assumed to use the default namespce.
      • createChild

        protected SimpleOutputElement createChild​(java.lang.String prefix,
                                                  java.lang.String localName,
                                                  java.lang.String uri)
        Full factory method, used for 'normal' namespace qualified output methods.
      • addToPool

        protected void addToPool​(SimpleOutputElement poolHead)
        Method called to temporarily link this instance to a pool, to allow reusing of instances with the same reader.
      • getNameDesc

        public java.lang.String getNameDesc()
        Specified by:
        getNameDesc in class OutputElementBase
        Returns:
        String presentation of the fully-qualified name, in "prefix:localName" format (no URI). Useful for error and debugging messages.
      • getPrefix

        public java.lang.String getPrefix()
      • getLocalName

        public java.lang.String getLocalName()
      • getNamespaceURI

        public java.lang.String getNamespaceURI()
      • getName

        public javax.xml.namespace.QName getName()
      • checkAttrWrite

        public void checkAttrWrite​(java.lang.String nsURI,
                                   java.lang.String localName)
                            throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • setPrefix

        public void setPrefix​(java.lang.String prefix)
      • setRootNsContext

        protected final void setRootNsContext​(javax.xml.namespace.NamespaceContext ctxt)
        Note: this method can and will only be called before outputting the root element.
        Specified by:
        setRootNsContext in class OutputElementBase