public class InputStreamWrapper
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private class |
InputStreamWrapper.WrappedStream
Stream that just uses the enclosing class to buffer input from the
wrapped stream.
|
private class |
InputStreamWrapper.WrappedStreamISO88591Reader
Reader for input stream using ISO8859-1 encoding.
|
private class |
InputStreamWrapper.WrappedStreamUTF8Reader
Reader for input stream using UTF-8 encoding.
|
Modifier and Type | Field and Description |
---|---|
private byte[] |
m_buffer
Cached reference to byte array used by buffer.
|
private IInByteBuffer |
m_byteBuffer
Input buffer.
|
private int |
m_emptyOffset
Current offset for generating character from buffer.
|
private java.lang.String |
m_encodingName
Name of encoding to be used for stream.
|
private int |
m_endOffset
Offset past end of bytes in buffer.
|
private int |
m_scanOffset
Scan position offset used for lookahead in buffer.
|
Constructor and Description |
---|
InputStreamWrapper() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close document input.
|
private boolean |
fillBuffer()
Reads data into the buffer.
|
IInByteBuffer |
getBuffer()
Get input buffer.
|
java.lang.String |
getEncoding()
Get encoding for input document.
|
java.io.Reader |
getReader()
Get reader for wrapped input stream.
|
private boolean |
isWhite(int chr)
Check if a character is XML whitespace.
|
private boolean |
require(int min)
Reads data into the buffer to at least a minimum number of bytes.
|
void |
reset()
Reset to initial state for reuse.
|
private java.lang.String |
scanQuoted()
Reads a quote delimited token from the scan position in the buffer.
|
private java.lang.String |
scanToken()
Reads a space or equals ('=') delimited token from the scan position in
the buffer.
|
void |
setBuffer(IInByteBuffer buff)
Set the input buffer.
|
void |
setEncoding(java.lang.String enc)
Set encoding for stream.
|
private IInByteBuffer m_byteBuffer
private java.lang.String m_encodingName
private byte[] m_buffer
private int m_endOffset
private int m_emptyOffset
private int m_scanOffset
public void setBuffer(IInByteBuffer buff)
buff
- public IInByteBuffer getBuffer()
null
if none setpublic void setEncoding(java.lang.String enc) throws java.io.IOException
enc
- character encoding used for input from stream
(null
if to be determined from XML input)java.io.IOException
- if unknown encoding, or encoding already setprivate boolean fillBuffer() throws java.io.IOException
true
if data has been read into buffer,
false
if notjava.io.IOException
- on error reading from streamprivate boolean require(int min) throws java.io.IOException
min
- number of bytes requiredtrue
if buffer contains at least the required byte
count on return, false
if notjava.io.IOException
- on error reading from wrapped streamprivate boolean isWhite(int chr)
chr
- true
if whitespace, false
if notprivate java.lang.String scanToken() throws java.io.IOException
java.io.IOException
- on error reading from wrapped streamprivate java.lang.String scanQuoted() throws java.io.IOException
java.io.IOException
- on error reading from wrapped streampublic java.io.Reader getReader() throws java.io.IOException
java.io.IOException
- if error reading from document or creating a reader
for the encoding foundpublic java.lang.String getEncoding()
getReader()
is called.public void close() throws java.io.IOException
java.io.IOException
- on error closing documentpublic void reset()