Interface XmlTokenSource

    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      XmlDocumentProperties documentProperties()
      Returns the XmlDocumentProperties object for the document this token source is associated with.
      void dump()
      Prints to stdout the state of the document in which this token source is positioned.
      org.w3c.dom.Node getDomNode()
      Returns a W3C DOM Node containing the XML represented by this source.
      java.lang.Object monitor()
      Returns the synchronization object for the document.
      XmlCursor newCursor()
      Returns a new XML cursor.
      org.w3c.dom.Node newDomNode()
      Returns a W3C DOM Node containing the XML represented by this source.
      org.w3c.dom.Node newDomNode​(XmlOptions options)
      Just like newDomNode() but with options.
      java.io.InputStream newInputStream()
      Returns a new stream containing standard XML text, encoded according to the given encoding.
      java.io.InputStream newInputStream​(XmlOptions options)
      Just like newInputStream(String encoding) but with options.
      java.io.Reader newReader()
      Returns a new character reader containing XML text.
      java.io.Reader newReader​(XmlOptions options)
      Just like newReader() but with options.
      XMLInputStream newXMLInputStream()
      Deprecated.
      XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
      XMLInputStream newXMLInputStream​(XmlOptions options)
      Deprecated.
      XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
      javax.xml.stream.XMLStreamReader newXMLStreamReader()
      Returns a new XMLStreamReader.
      javax.xml.stream.XMLStreamReader newXMLStreamReader​(XmlOptions options)
      Just like newXMLInputStream() but with options.
      void save​(java.io.File file)
      Writes the XML represented by this source to the given File.
      void save​(java.io.File file, XmlOptions options)
      Writes the XML represented by this source to the given File.
      void save​(java.io.OutputStream os)
      Writes the XML represented by this source to the given output stream.
      void save​(java.io.OutputStream os, XmlOptions options)
      Writes the XML represented by this source to the given output stream.
      void save​(java.io.Writer w)
      Writes the XML represented by this source to the given output.
      void save​(java.io.Writer w, XmlOptions options)
      Writes the XML represented by this source to the given output.
      void save​(org.xml.sax.ContentHandler ch, org.xml.sax.ext.LexicalHandler lh)
      Writes the XML represented by this source to the given SAX content and lexical handlers.
      void save​(org.xml.sax.ContentHandler ch, org.xml.sax.ext.LexicalHandler lh, XmlOptions options)
      Writes the XML represented by this source to the given SAX content and lexical handlers.
      java.lang.String xmlText()
      Returns standard XML text.
      java.lang.String xmlText​(XmlOptions options)
      Just like xmlText() but with options.
    • Method Detail

      • monitor

        java.lang.Object monitor()
        Returns the synchronization object for the document. If concurrent multithreaded access to a document is required, the access should should be protected by synchronizing on this monitor() object. There is one monitor per XML document tree.
      • documentProperties

        XmlDocumentProperties documentProperties()
        Returns the XmlDocumentProperties object for the document this token source is associated with.
      • newCursor

        XmlCursor newCursor()
        Returns a new XML cursor. A cursor provides random access to all the tokens in the XML data, plus the ability to extract strongly-typed XmlObjects for the data. If the data is not read-only, the XML cursor also allows modifications to the data. Using a cursor for the first time typically forces the XML document into memory.
      • newXMLInputStream

        XMLInputStream newXMLInputStream()
        Deprecated.
        XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
        Returns a new XmlInputStream. The stream starts at the current begin-tag or begin-document position and ends at the matching end-tag or end-document. This is a fail-fast stream, so if the underlying data is changed while the stream is being read, the stream throws a ConcurrentModificationException. Throws an IllegalStateException if the XmlTokenSource is not positioned at begin-tag or begin-document (e.g., if it is at an attribute).
      • newXMLStreamReader

        javax.xml.stream.XMLStreamReader newXMLStreamReader()
        Returns a new XMLStreamReader. The stream starts at the current begin-tag or begin-document position and ends at the matching end-tag or end-document. This is a fail-fast stream, so if the underlying data is changed while the stream is being read, the stream throws a ConcurrentModificationException.
      • xmlText

        java.lang.String xmlText()
        Returns standard XML text.

        The text returned represents the document contents starting at the current begin-tag or begin-document and ending at the matching end-tag or end-document. This is same content as newReader, but it is returned as a single string.

        Throws an IllegalStateException if the XmlTokenSource is not positioned at begin-tag or begin-document (e.g., if it is at an attribute).

        Note that this method does not produce XML with the XML declaration, including the encoding information. To save the XML declaration with the XML, see save(OutputStream) or save(OutputStream, XmlOptions).

      • newInputStream

        java.io.InputStream newInputStream()
        Returns a new stream containing standard XML text, encoded according to the given encoding. The byte stream contains contents starting at the current begin-tag or begin-document and ending at the matching end-tag or end-document. The specified encoding is used and also emitted in a PI at the beginning of the stream. This is a fail-fast stream, so if the underlying data is changed while the stream is being read, the stream throws a ConcurrentModificationException. Throws an IllegalStateException if the XmlTokenSource is not positioned at begin-tag or begin-document (e.g., if it is at an attribute).
      • newReader

        java.io.Reader newReader()
        Returns a new character reader containing XML text. The contents of the reader represents the document contents starting at the current begin-tag or begin-document and ending at the matching end-tag or end-document. No encoding annotation will be made in the text itself. This is a fail-fast reader, so if the underlying data is changed while the reader is being read, the reader throws a ConcurrentModificationException. Throws an IllegalStateException if the XmlTokenSource is not positioned at begin-tag or begin-document (e.g., if it is at an attribute).
      • newDomNode

        org.w3c.dom.Node newDomNode()
        Returns a W3C DOM Node containing the XML represented by this source. This is a copy of the XML, it is not a live with the underlying store of this token source. If this is the document node, then a Document is returned, else a DocumentFragment is returned.
      • getDomNode

        org.w3c.dom.Node getDomNode()
        Returns a W3C DOM Node containing the XML represented by this source. This is a live DOM node, not a copy. Any changes made through this node are immediately reflected in the document associated with this token source. Depending on the kind of token this XmlTokenSource represents, an appropriate node will be returned.
      • save

        void save​(org.xml.sax.ContentHandler ch,
                  org.xml.sax.ext.LexicalHandler lh)
           throws org.xml.sax.SAXException
        Writes the XML represented by this source to the given SAX content and lexical handlers. Note that this method does not save the XML declaration, including the encoding information. To save the XML declaration with the XML, see save(OutputStream), save(OutputStream, XmlOptions), save(File) or save(File, XmlOptions).
        Throws:
        org.xml.sax.SAXException
      • save

        void save​(java.io.File file)
           throws java.io.IOException
        Writes the XML represented by this source to the given File. This method will save the XML declaration, including encoding information, with the XML.
        Throws:
        java.io.IOException
      • save

        void save​(java.io.OutputStream os)
           throws java.io.IOException
        Writes the XML represented by this source to the given output stream. This method will save the XML declaration, including encoding information, with the XML.
        Throws:
        java.io.IOException
      • newXMLStreamReader

        javax.xml.stream.XMLStreamReader newXMLStreamReader​(XmlOptions options)
        Just like newXMLInputStream() but with options. Options map may be null.
        See Also:
        XmlOptions
      • xmlText

        java.lang.String xmlText​(XmlOptions options)
        Just like xmlText() but with options. Options map may be null.

        Note that this method does not produce XML with the XML declaration, including the encoding information. To save the XML declaration with the XML, see save(OutputStream) or save(OutputStream, XmlOptions).

        See Also:
        XmlOptions
      • newInputStream

        java.io.InputStream newInputStream​(XmlOptions options)
        Just like newInputStream(String encoding) but with options. Options map may be null.
        See Also:
        XmlOptions
      • newReader

        java.io.Reader newReader​(XmlOptions options)
        Just like newReader() but with options. Options map may be null.
        See Also:
        XmlOptions
      • newDomNode

        org.w3c.dom.Node newDomNode​(XmlOptions options)
        Just like newDomNode() but with options. Options map may be null.
        See Also:
        XmlOptions
      • save

        void save​(org.xml.sax.ContentHandler ch,
                  org.xml.sax.ext.LexicalHandler lh,
                  XmlOptions options)
           throws org.xml.sax.SAXException
        Writes the XML represented by this source to the given SAX content and lexical handlers. Note that this method does not save the XML declaration, including the encoding information. To save the XML declaration with the XML, see save(OutputStream), save(OutputStream, XmlOptions), save(File) or save(File, XmlOptions).
        Throws:
        org.xml.sax.SAXException
      • save

        void save​(java.io.File file,
                  XmlOptions options)
           throws java.io.IOException
        Writes the XML represented by this source to the given File. This method will save the XML declaration, including encoding information, with the XML.
        Throws:
        java.io.IOException
      • save

        void save​(java.io.OutputStream os,
                  XmlOptions options)
           throws java.io.IOException
        Writes the XML represented by this source to the given output stream. This method will save the XML declaration, including encoding information, with the XML.
        Throws:
        java.io.IOException
      • dump

        void dump()
        Prints to stdout the state of the document in which this token source is positioned. This is very implementation specific and may change at any time. Dump can be useful for debugging purposes. It is very different from the save methods which produce XML text which only approximates the actual state of the document.