org.eclipse.ercp.xml.io
Class XmlInputStreamReader

java.lang.Object
  extended by java.io.Reader
      extended by org.eclipse.ercp.xml.io.XmlInputStreamReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class XmlInputStreamReader
extends java.io.Reader

Implement a dedicated InputStreamReader for an XML file which can change dynamically for an other encoding Used when reading an XML file...


Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
XmlInputStreamReader(java.io.InputStream in)
          Constructs a new XmlInputStreamReader on the InputStream in.
XmlInputStreamReader(java.io.InputStream in, java.lang.String ianaEncoding)
          Constructs a new XmlInputStreamReader on the InputStream in.
 
Method Summary
 void close()
          Close this Reader.
 int read()
          Reads a single character from this reader and returns the result as an int.
 int read(char[] buf, int offset, int count)
          Reads at most count characters from this Reader and stores them at offset in the character array buf.
 void setEncoding(java.lang.String ianaEncoding)
           
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlInputStreamReader

public XmlInputStreamReader(java.io.InputStream in)
                     throws java.io.IOException
Constructs a new XmlInputStreamReader on the InputStream in. The default buffer size (2K) is allocated and all reads can now be filtered through this stream.

Parameters:
in - the InputStream to buffer reads on.
Throws:
java.io.IOException

XmlInputStreamReader

public XmlInputStreamReader(java.io.InputStream in,
                            java.lang.String ianaEncoding)
                     throws java.io.IOException
Constructs a new XmlInputStreamReader on the InputStream in. The buffer size is specified by the parameter size and all reads can now be filtered through this XmlInputStreamReader.

Parameters:
in - the InputStream to buffer reads on.
enc - the java encoding name.
Throws:
java.io.IOException
Method Detail

setEncoding

public void setEncoding(java.lang.String ianaEncoding)
                 throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

read

public final int read()
               throws java.io.IOException
Reads a single character from this reader and returns the result as an int. The 2 higher-order characters are set to 0. If the end of reader was encountered then return -1.

Overrides:
read in class java.io.Reader
Returns:
the character read or -1 if end of reader.
Throws:
java.io.IOException - If the Reader is already closed or some other IO error occurs.

read

public final int read(char[] buf,
                      int offset,
                      int count)
               throws java.io.IOException
Reads at most count characters from this Reader and stores them at offset in the character array buf. Returns the number of characters actually read or -1 if the end of reader was encountered.

Specified by:
read in class java.io.Reader
Parameters:
buf - character array to store the read characters
offset - offset in buf to store the read characters
count - maximum number of characters to read
Returns:
the number of characters read or -1 if end of reader.
Throws:
java.io.IOException - If the Reader is already closed or some other IO error occurs.

close

public void close()
           throws java.io.IOException
Close this Reader. This must be implemented by any concrete subclasses. The implementation should free any resources associated with the Reader.

Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Reader
Throws:
java.io.IOException - If an error occurs attempting to close this Reader.