Class XmlTokenStream


  • public class XmlTokenStream
    extends java.lang.Object
    Simple helper class used on top of STAX XMLStreamReader to further abstract out all irrelevant details, and to expose equivalent of flat token stream with no "fluff" tokens (comments, processing instructions, mixed content) all of which is just to simplify actual higher-level conversion to JSON tokens.

    Beyond initial idea there are also couple of other detours like ability to "replay" some tokens, add virtual wrappers (ironically to support "unwrapped" array values), and to unroll "Objects" into String values in some cases.

    • Constructor Detail

      • XmlTokenStream

        public XmlTokenStream​(javax.xml.stream.XMLStreamReader xmlReader,
                              ContentReference sourceRef,
                              int formatFeatures,
                              XmlNameProcessor nameProcessor)
    • Method Detail

      • initialize

        public int initialize()
                       throws javax.xml.stream.XMLStreamException
        Second part of initialization, to be called immediately after construction
        Throws:
        javax.xml.stream.XMLStreamException
        Since:
        2.12
      • getXmlReader

        public org.codehaus.stax2.XMLStreamReader2 getXmlReader()
      • next

        public int next()
                 throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • skipEndElement

        public void skipEndElement()
                            throws java.io.IOException,
                                   javax.xml.stream.XMLStreamException
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • getCurrentToken

        public int getCurrentToken()
      • getText

        public java.lang.String getText()
      • getLocalName

        public java.lang.String getLocalName()
        Accessor for local name of current named event (that is, XML_START_ELEMENT or XML_ATTRIBUTE_NAME).

        NOTE: name NOT accessible on XML_END_ELEMENT

      • getNamespaceURI

        public java.lang.String getNamespaceURI()
      • hasXsiNil

        public boolean hasXsiNil()
      • closeCompletely

        public void closeCompletely()
                             throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • close

        public void close()
                   throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getCurrentLocation

        public JsonLocation getCurrentLocation()