com.bluecast.xml
Class XMLStreamReader

java.lang.Object
  |
  +--java.io.Reader
        |
        +--com.bluecast.xml.XMLInputReader
              |
              +--com.bluecast.xml.XMLStreamReader

public final class XMLStreamReader
extends XMLInputReader

A Reader for XML documents and streams. This class automatically determines the proper character set to use based on Byte Order Marks and XML declarations.

Version:
$Revision: 1.2 $
Author:
Yuval Oren, yuval@bluecast.com

Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
XMLStreamReader()
          Create an XMLStreamReader without providing an InputStream yet.
XMLStreamReader(java.io.InputStream in, boolean rewindDeclaration)
          Creates an XMLStreamReader.
XMLStreamReader(java.io.InputStream in, java.lang.String encoding, boolean rewindDeclaration)
          Creates an XMLStreamReader while specifying a character encoding.
 
Method Summary
 void close()
           
 java.lang.String getEncoding()
          Returns the character set being used by the reader.
 void mark(int readAheadLimit)
           
 boolean markSupported()
           
 int read()
           
 int read(char[] destbuf)
           
 int read(char[] destbuf, int off, int len)
           
 boolean ready()
           
 void reset()
           
 void reset(java.io.InputStream in, java.lang.String encoding, boolean rewindDeclaration)
          Reuses this XMLStreamReader for a different InputStream.
 long skip(long n)
           
 
Methods inherited from class com.bluecast.xml.XMLInputReader
getXMLDeclaredEncoding, getXMLVersion, isXMLStandalone, isXMLStandaloneDeclared, parseXMLDeclaration, resetInput
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLStreamReader

public XMLStreamReader()
Create an XMLStreamReader without providing an InputStream yet. You must call reset() before using.


XMLStreamReader

public XMLStreamReader(java.io.InputStream in,
                       boolean rewindDeclaration)
                throws java.io.IOException
Creates an XMLStreamReader.

Parameters:
in - the InputStream
rewindDeclaration - a value of false will skip past any XML declaration. True will dish out the entire document.

XMLStreamReader

public XMLStreamReader(java.io.InputStream in,
                       java.lang.String encoding,
                       boolean rewindDeclaration)
                throws java.io.IOException
Creates an XMLStreamReader while specifying a character encoding.

Method Detail

reset

public void reset(java.io.InputStream in,
                  java.lang.String encoding,
                  boolean rewindDeclaration)
           throws java.io.IOException
Reuses this XMLStreamReader for a different InputStream.

java.io.IOException

getEncoding

public java.lang.String getEncoding()
Returns the character set being used by the reader. Note that the encoding in the XML declaration is ignored if it is not needed to determine the character set.


close

public void close()
           throws java.io.IOException
Specified by:
close in class java.io.Reader
java.io.IOException

mark

public void mark(int readAheadLimit)
          throws java.io.IOException
Overrides:
mark in class java.io.Reader
java.io.IOException

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.Reader

read

public int read()
         throws java.io.IOException
Overrides:
read in class java.io.Reader
java.io.IOException

read

public int read(char[] destbuf)
         throws java.io.IOException
Overrides:
read in class java.io.Reader
java.io.IOException

read

public int read(char[] destbuf,
                int off,
                int len)
         throws java.io.IOException
Specified by:
read in class java.io.Reader
java.io.IOException

ready

public boolean ready()
              throws java.io.IOException
Overrides:
ready in class java.io.Reader
java.io.IOException

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class java.io.Reader
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.Reader
java.io.IOException