org.openmdx.kernel.xml
Class AdaptiveInputStreamReader

java.lang.Object
  extended by java.io.Reader
      extended by org.openmdx.kernel.xml.AdaptiveInputStreamReader
All Implemented Interfaces:
Closeable, Readable

public class AdaptiveInputStreamReader
extends Reader

The Adaptive Input Stream Reader has the following encoding priorities

  1. The constructor's encoding argument
  2. A byte order mark
  3. An XML declaration's encoding attribute
  4. The platform's default encoding


Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
AdaptiveInputStreamReader(InputStream in, String encoding, boolean byteOrderMarkAware, boolean xmlDeclarationAware)
          Constructor
 
Method Summary
 void close()
           
 String getByteOrderMark()
          Retrieve the byte order mark evaluation result.
 String getEncoding()
           
 XMLDeclaration getXMLDclaration()
          The AdaptiveInputStreamReader does not keep a reference to the XMLDeclaration returned by this method.
 void mark(int readAheadLimit)
           
 boolean markSupported()
           
 int read()
           
 int read(char[] cbuf)
           
 int read(char[] cbuf, int off, int len)
           
 boolean ready()
           
 void reset()
           
 long skip(long n)
           
 
Methods inherited from class java.io.Reader
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdaptiveInputStreamReader

public AdaptiveInputStreamReader(InputStream in,
                                 String encoding,
                                 boolean byteOrderMarkAware,
                                 boolean xmlDeclarationAware)
                          throws IOException
Constructor

Parameters:
in -
encoding; - may be null
byteOrderMarkAware -
xmlDeclarationAware -
Throws:
IOException
Method Detail

getEncoding

public String getEncoding()
Returns:

getByteOrderMark

public String getByteOrderMark()
Retrieve the byte order mark evaluation result.

Returns:
the byte order makr's encoding; or null.

getXMLDclaration

public XMLDeclaration getXMLDclaration()
The AdaptiveInputStreamReader does not keep a reference to the XMLDeclaration returned by this method.

Returns:
a copy of the XML Declaration; or null

mark

public void mark(int readAheadLimit)
          throws IOException
Overrides:
mark in class Reader
Throws:
IOException

markSupported

public boolean markSupported()
Overrides:
markSupported in class Reader

read

public int read()
         throws IOException
Overrides:
read in class Reader
Throws:
IOException

read

public int read(char[] cbuf,
                int off,
                int len)
         throws IOException
Specified by:
read in class Reader
Throws:
IOException

read

public int read(char[] cbuf)
         throws IOException
Overrides:
read in class Reader
Throws:
IOException

ready

public boolean ready()
              throws IOException
Overrides:
ready in class Reader
Throws:
IOException

reset

public void reset()
           throws IOException
Overrides:
reset in class Reader
Throws:
IOException

skip

public long skip(long n)
          throws IOException
Overrides:
skip in class Reader
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in class Reader
Throws:
IOException


This software is published under the BSD license. Copyright © 2003-2007, OMEX AG, Switzerland, All rights reserved. Use is subject to license terms.