Class StdXMLReader

  • All Implemented Interfaces:
    IXMLReader

    public class StdXMLReader
    extends Object
    implements IXMLReader
    StdXMLReader reads the data to be parsed.
    Version:
    $Name: RELEASE_2_2_1 $, $Revision: 1.4 $
    Author:
    Marc De Scheemaecker
    • Constructor Detail

      • StdXMLReader

        public StdXMLReader​(Reader reader)
        Initializes the XML reader.
        Parameters:
        reader - the input for the XML data.
      • StdXMLReader

        public StdXMLReader​(InputStream stream)
                     throws IOException
        Initializes the XML reader.
        Parameters:
        stream - the input for the XML data.
        Throws:
        IOException - if an I/O error occurred
    • Method Detail

      • stringReader

        public static IXMLReader stringReader​(String str)
        Creates a new reader using a string as input.
        Parameters:
        str - the string containing the XML data
      • getEncoding

        protected String getEncoding​(String str)
        Scans the encoding from an <?xml...?> tag.
        Parameters:
        str - the first tag in the XML data.
        Returns:
        the encoding, or null if no encoding has been specified.
      • stream2reader

        protected Reader stream2reader​(InputStream stream,
                                       StringBuffer charsRead)
                                throws IOException
        Converts a stream to a reader while detecting the encoding.
        Parameters:
        stream - the input for the XML data.
        charsRead - buffer where to put characters that have been read
        Throws:
        IOException - if an I/O error occurred
      • read

        public char read()
                  throws IOException
        Reads a character.
        Specified by:
        read in interface IXMLReader
        Returns:
        the character
        Throws:
        IOException - if no character could be read
      • atEOFOfCurrentStream

        public boolean atEOFOfCurrentStream()
                                     throws IOException
        Returns true if the current stream has no more characters left to be read.
        Specified by:
        atEOFOfCurrentStream in interface IXMLReader
        Throws:
        IOException - if an I/O error occurred
      • atEOF

        public boolean atEOF()
                      throws IOException
        Returns true if there are no more characters left to be read.
        Specified by:
        atEOF in interface IXMLReader
        Throws:
        IOException - if an I/O error occurred
      • unread

        public void unread​(char ch)
                    throws IOException
        Pushes the last character read back to the stream.
        Specified by:
        unread in interface IXMLReader
        Parameters:
        ch - the character to push back.
        Throws:
        IOException - if an I/O error occurred
      • startNewStream

        public void startNewStream​(Reader reader)
        Starts a new stream from a Java reader. The new stream is used temporary to read data from. If that stream is exhausted, control returns to the parent stream.
        Specified by:
        startNewStream in interface IXMLReader
        Parameters:
        reader - the non-null reader to read the new data from
      • startNewStream

        public void startNewStream​(Reader reader,
                                   boolean isInternalEntity)
        Starts a new stream from a Java reader. The new stream is used temporary to read data from. If that stream is exhausted, control returns to the parent stream.
        Specified by:
        startNewStream in interface IXMLReader
        Parameters:
        reader - the non-null reader to read the new data from
        isInternalEntity - true if the reader is produced by resolving an internal entity
      • getStreamLevel

        public int getStreamLevel()
        Returns the current "level" of the stream on the stack of streams.
        Specified by:
        getStreamLevel in interface IXMLReader
      • getLineNr

        public int getLineNr()
        Returns the line number of the data in the current stream.
        Specified by:
        getLineNr in interface IXMLReader
      • setPublicID

        public void setPublicID​(String publicID)
        Sets the public ID of the current stream.
        Specified by:
        setPublicID in interface IXMLReader
        Parameters:
        publicID - the public ID