Class XmlHeaderAwareReader
- java.lang.Object
-
- java.io.Reader
-
- com.thoughtworks.xstream.core.util.XmlHeaderAwareReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Readable
public final class XmlHeaderAwareReader extends java.io.Reader
AReader
that evaluates the XML header. It selects its encoding based on the encoding read with the XML header of the providedInputStream
. 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
- Author:
- Jörg Schaible
-
-
Constructor Summary
Constructors Constructor Description XmlHeaderAwareReader(java.io.InputStream in)
Constructs an XmlHeaderAwareReader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
equals(java.lang.Object obj)
java.lang.String
getEncoding()
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()
-
-
-
Constructor Detail
-
XmlHeaderAwareReader
public XmlHeaderAwareReader(java.io.InputStream in) throws java.io.UnsupportedEncodingException, java.io.IOException
Constructs an XmlHeaderAwareReader.- Parameters:
in
- theInputStream
- Throws:
java.io.UnsupportedEncodingException
- if the encoding is not supportedjava.io.IOException
- occurred while reading the XML header- Since:
- 1.3
-
-
Method Detail
-
getEncoding
public java.lang.String getEncoding()
- Since:
- 1.3
- See Also:
InputStreamReader.getEncoding()
-
getVersion
public double getVersion()
- Since:
- 1.3
- See Also:
InputStreamReader.getEncoding()
-
mark
public void mark(int readAheadLimit) throws java.io.IOException
- Overrides:
mark
in classjava.io.Reader
- Throws:
java.io.IOException
- See Also:
Reader.mark(int)
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classjava.io.Reader
- See Also:
Reader.markSupported()
-
read
public int read() throws java.io.IOException
- Overrides:
read
in classjava.io.Reader
- Throws:
java.io.IOException
- See Also:
Reader.read()
-
read
public int read(char[] cbuf, int offset, int length) throws java.io.IOException
- Specified by:
read
in classjava.io.Reader
- Throws:
java.io.IOException
- See Also:
Reader.read(char[], int, int)
-
read
public int read(char[] cbuf) throws java.io.IOException
- Overrides:
read
in classjava.io.Reader
- Throws:
java.io.IOException
- See Also:
Reader.read(char[])
-
ready
public boolean ready() throws java.io.IOException
- Overrides:
ready
in classjava.io.Reader
- Throws:
java.io.IOException
- See Also:
Reader.ready()
-
reset
public void reset() throws java.io.IOException
- Overrides:
reset
in classjava.io.Reader
- Throws:
java.io.IOException
- See Also:
Reader.reset()
-
skip
public long skip(long n) throws java.io.IOException
- Overrides:
skip
in classjava.io.Reader
- Throws:
java.io.IOException
- See Also:
Reader.skip(long)
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Reader
- Throws:
java.io.IOException
- See Also:
Reader.close()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
-