public final class XmlHeaderAwareReader
extends java.io.Reader
Reader
that evaluates the XML header. It selects its encoding based on the encoding read with the XML
header of the provided InputStream
. The default encoding is UTF-8 and the version is 1.0 if the
stream does not contain an XML header or the attributes are not set within the header.Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
KEY_ENCODING |
private static java.lang.String |
KEY_VERSION |
private java.io.InputStreamReader |
reader |
private static int |
STATE_ATTR_NAME |
private static int |
STATE_ATTR_VALUE |
private static int |
STATE_AWAIT_XML_HEADER |
private static int |
STATE_BOM |
private static int |
STATE_START |
private double |
version |
private static java.lang.String |
XML_TOKEN |
Constructor and Description |
---|
XmlHeaderAwareReader(java.io.InputStream in)
Constructs an XmlHeaderAwareReader.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
boolean |
equals(java.lang.Object obj) |
java.lang.String |
getEncoding() |
private java.util.Map |
getHeader(java.io.PushbackInputStream[] in) |
double |
getVersion() |
int |
hashCode() |
void |
mark(int readAheadLimit) |
boolean |
markSupported() |
int |
read() |
int |
read(char[] cbuf) |
int |
read(char[] cbuf,
int offset,
int length) |
boolean |
ready() |
void |
reset() |
long |
skip(long n) |
java.lang.String |
toString() |
private final java.io.InputStreamReader reader
private final double version
private static final java.lang.String KEY_ENCODING
private static final java.lang.String KEY_VERSION
private static final java.lang.String XML_TOKEN
private static final int STATE_BOM
private static final int STATE_START
private static final int STATE_AWAIT_XML_HEADER
private static final int STATE_ATTR_NAME
private static final int STATE_ATTR_VALUE
public XmlHeaderAwareReader(java.io.InputStream in) throws java.io.UnsupportedEncodingException, java.io.IOException
in
- the InputStream
java.io.UnsupportedEncodingException
- if the encoding is not supportedjava.io.IOException
- occurred while reading the XML headerprivate java.util.Map getHeader(java.io.PushbackInputStream[] in) throws java.io.IOException
java.io.IOException
public java.lang.String getEncoding()
InputStreamReader.getEncoding()
public double getVersion()
InputStreamReader.getEncoding()
public void mark(int readAheadLimit) throws java.io.IOException
mark
in class java.io.Reader
java.io.IOException
Reader.mark(int)
public boolean markSupported()
markSupported
in class java.io.Reader
Reader.markSupported()
public int read() throws java.io.IOException
read
in class java.io.Reader
java.io.IOException
Reader.read()
public int read(char[] cbuf, int offset, int length) throws java.io.IOException
read
in class java.io.Reader
java.io.IOException
Reader.read(char[], int, int)
public int read(char[] cbuf) throws java.io.IOException
read
in class java.io.Reader
java.io.IOException
Reader.read(char[])
public boolean ready() throws java.io.IOException
ready
in class java.io.Reader
java.io.IOException
Reader.ready()
public void reset() throws java.io.IOException
reset
in class java.io.Reader
java.io.IOException
Reader.reset()
public long skip(long n) throws java.io.IOException
skip
in class java.io.Reader
java.io.IOException
Reader.skip(long)
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.Reader
java.io.IOException
Reader.close()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Object.equals(java.lang.Object)
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()