Class InterningXmlVisitor

  • All Implemented Interfaces:
    XmlVisitor

    public final class InterningXmlVisitor
    extends java.lang.Object
    implements XmlVisitor
    XmlVisitor decorator that interns all string tokens.
    Author:
    Kohsuke Kawaguchi
    • Constructor Detail

      • InterningXmlVisitor

        public InterningXmlVisitor​(XmlVisitor next)
    • Method Detail

      • startDocument

        public void startDocument​(LocatorEx locator,
                                  javax.xml.namespace.NamespaceContext nsContext)
                           throws org.xml.sax.SAXException
        Description copied from interface: XmlVisitor
        Notifies a start of the document.
        Specified by:
        startDocument in interface XmlVisitor
        Parameters:
        locator - This live object returns the location information as the parsing progresses. must not be null.
        nsContext - Some broken XML APIs can't iterate all the in-scope namespace bindings, which makes it impossible to emulate XmlVisitor.startPrefixMapping(String, String) correctly when unmarshalling a subtree. Connectors that use such an API can pass in additional NamespaceContext object that knows about the in-scope namespace bindings. Otherwise (and normally) it is null.

        Ideally this object should be immutable and only represent the namespace URI bindings in the context (those done above the element that JAXB started unmarshalling), but it can also work even if it changes as the parsing progress (to include namespaces declared on the current element being parsed.)

        Throws:
        org.xml.sax.SAXException
      • endDocument

        public void endDocument()
                         throws org.xml.sax.SAXException
        Specified by:
        endDocument in interface XmlVisitor
        Throws:
        org.xml.sax.SAXException
      • startElement

        public void startElement​(TagName tagName)
                          throws org.xml.sax.SAXException
        Description copied from interface: XmlVisitor
        Notifies a start tag of a new element. namespace URIs and local names must be interned.
        Specified by:
        startElement in interface XmlVisitor
        Throws:
        org.xml.sax.SAXException
      • endElement

        public void endElement​(TagName tagName)
                        throws org.xml.sax.SAXException
        Specified by:
        endElement in interface XmlVisitor
        Throws:
        org.xml.sax.SAXException
      • text

        public void text​(java.lang.CharSequence pcdata)
                  throws org.xml.sax.SAXException
        Description copied from interface: XmlVisitor
        Text events.

        The caller should consult XmlVisitor.TextPredictor to see if the unmarshaller is expecting any PCDATA. If the above is returning false, the caller is OK to skip any text in XML. The net effect is that we can ignore whitespaces quickly.

        Specified by:
        text in interface XmlVisitor
        Parameters:
        pcdata - represents character data. This object can be mutable (such as StringBuilder); it only needs to be fixed while this method is executing.
        Throws:
        org.xml.sax.SAXException