Class XmlHeaderAwareReader
java.lang.Object
java.io.Reader
com.thoughtworks.xstream.core.util.XmlHeaderAwareReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
A
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.- Since:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final String
private final InputStreamReader
private static final int
private static final int
private static final int
private static final int
private static final int
private final double
private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
boolean
private Map
getHeader
(PushbackInputStream[] in) double
int
hashCode()
void
mark
(int readAheadLimit) boolean
int
read()
int
read
(char[] cbuf) int
read
(char[] cbuf, int offset, int length) boolean
ready()
void
reset()
long
skip
(long n) toString()
Methods inherited from class java.io.Reader
nullReader, read, transferTo
-
Field Details
-
reader
-
version
private final double version -
KEY_ENCODING
- See Also:
-
KEY_VERSION
- See Also:
-
XML_TOKEN
- See Also:
-
STATE_BOM
private static final int STATE_BOM- See Also:
-
STATE_START
private static final int STATE_START- See Also:
-
STATE_AWAIT_XML_HEADER
private static final int STATE_AWAIT_XML_HEADER- See Also:
-
STATE_ATTR_NAME
private static final int STATE_ATTR_NAME- See Also:
-
STATE_ATTR_VALUE
private static final int STATE_ATTR_VALUE- See Also:
-
-
Constructor Details
-
XmlHeaderAwareReader
Constructs an XmlHeaderAwareReader.- Parameters:
in
- theInputStream
- Throws:
UnsupportedEncodingException
- if the encoding is not supportedIOException
- occurred while reading the XML header- Since:
- 1.3
-
-
Method Details
-
getHeader
- Throws:
IOException
-
getEncoding
- Since:
- 1.3
- See Also:
-
getVersion
public double getVersion()- Since:
- 1.3
- See Also:
-
mark
- Overrides:
mark
in classReader
- Throws:
IOException
- See Also:
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in classReader
- See Also:
-
read
- Overrides:
read
in classReader
- Throws:
IOException
- See Also:
-
read
- Specified by:
read
in classReader
- Throws:
IOException
- See Also:
-
read
- Overrides:
read
in classReader
- Throws:
IOException
- See Also:
-
ready
- Overrides:
ready
in classReader
- Throws:
IOException
- See Also:
-
reset
- Overrides:
reset
in classReader
- Throws:
IOException
- See Also:
-
skip
- Overrides:
skip
in classReader
- Throws:
IOException
- See Also:
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
- See Also:
-
equals
-
hashCode
public int hashCode() -
toString
-