Top Description Fields Constructors Methods
com.ctc.wstx.io

pack-priv abstract Class BaseReader

extends Reader
Class Inheritance
Known Direct Subclasses
com.ctc.wstx.io.ISOLatinReader, com.ctc.wstx.io.UTF32Reader, com.ctc.wstx.io.UTF8Reader, com.ctc.wstx.io.AsciiReader
Imports
java.io.*, com.ctc.wstx.api.ReaderConfig

Simple basic class for optimized Readers Woodstox has; implements "cookie-cutter" methods that are used by all actual implementations.

Field Summary

Modifier and TypeField and Description
pack-priv static final char
CHAR_DEL

DEL character is both the last ascii char, and illegal in xml 1.1.

protected static final char
CONVERT_LSEP_TO

In xml 1.1, LSEP bit like \n, or \r. Need to choose one as the result.

protected static final char
CONVERT_NEL_TO

In xml 1.1, NEL (0x85) behaves much the way \n does (can be follow \r as part of the linefeed

protected byte[]
protected int
mByteBufferEnd

Pointed to the end marker, that is, position one after the last valid available byte.

protected int
mBytePtr

Pointer to the next available byte (if any), iff less than mByteBufferEnd

protected final ReaderConfig
private InputStream
private final boolean
mRecycleBuffer

Flag that indicates whether the read buffer is to be recycled when Reader is closed or not.

protected char[]
protected static final char
protected static final char
Inherited from java.io.Reader:
lock

Constructor Summary

AccessConstructor and Description
protected
BaseReader(ReaderConfig cfg, InputStream in, byte[] buf, int ptr, int len, boolean recycleBuffer)

Method Summary

Modifier and TypeMethod and Description
protected final boolean
canModifyBuffer()

Method that can be used to see if we can actually modify the underlying buffer.

public void
close()

Implements abstract java.io.Reader.close.

Implements java.io.Closeable.close.

Closes the stream and releases any system resources associated with it.

public final void
freeBuffers()

This method should be called along with (or instead of) normal close.

protected final InputStream
public int
read()

Overrides java.io.Reader.read.

Although this method is implemented by the base class, AND it should never be called by Woodstox code, let's still implement it bit more efficiently just in case

protected final int
readBytes()

Method for reading as many bytes from the underlying stream as possible (that fit in the buffer), to the beginning of the buffer.

protected final int

Returns:

Number of bytes read, if any; -1 to indicate none available (that is, end of input)
readBytesAt
(int offset)

Method for reading as many bytes from the underlying stream as possible (that fit in the buffer considering offset), to the specified offset.

protected void
reportBounds(char[] cbuf, int start, int len)

protected void
reportInvalidXml11(int value, int bytePos, int charPos)

protected void
public abstract void
setXmlCompliancy(int xmlVersion)

Method that can be called to indicate the xml conformance used when reading content using this reader.

Inherited from java.io.Reader:
markmarkSupportednullReaderreadreadreadreadyresetskiptransferTo

Field Detail

CHAR_DELback to summary
pack-priv static final char CHAR_DEL

DEL character is both the last ascii char, and illegal in xml 1.1.

CONVERT_LSEP_TOback to summary
protected static final char CONVERT_LSEP_TO

In xml 1.1, LSEP bit like \n, or \r. Need to choose one as the result. Let's use \n, for simplicity

CONVERT_NEL_TOback to summary
protected static final char CONVERT_NEL_TO

In xml 1.1, NEL (0x85) behaves much the way \n does (can be follow \r as part of the linefeed

mByteBufferback to summary
protected byte[] mByteBuffer
mByteBufferEndback to summary
protected int mByteBufferEnd

Pointed to the end marker, that is, position one after the last valid available byte.

mBytePtrback to summary
protected int mBytePtr

Pointer to the next available byte (if any), iff less than mByteBufferEnd

mConfigback to summary
protected final ReaderConfig mConfig
mInback to summary
private InputStream mIn
mRecycleBufferback to summary
private final boolean mRecycleBuffer

Flag that indicates whether the read buffer is to be recycled when Reader is closed or not.

mTmpBufback to summary
protected char[] mTmpBuf
NULL_BYTEback to summary
protected static final char NULL_BYTE
NULL_CHARback to summary
protected static final char NULL_CHAR

Constructor Detail

BaseReaderback to summary
protected BaseReader(ReaderConfig cfg, InputStream in, byte[] buf, int ptr, int len, boolean recycleBuffer)

Method Detail

canModifyBufferback to summary
protected final boolean canModifyBuffer()

Method that can be used to see if we can actually modify the underlying buffer. This is the case if we are managing the buffer, but not if it was just given to us.

closeback to summary
public void close() throws IOException

Implements abstract java.io.Reader.close.

Implements java.io.Closeable.close.

Doc from java.io.Reader.close.

Closes the stream and releases any system resources associated with it. Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
freeBuffersback to summary
public final void freeBuffers()

This method should be called along with (or instead of) normal close. After calling this method, no further reads should be tried. Method will try to recycle read buffers (if any).

getStreamback to summary
protected final InputStream getStream()
readback to summary
public int read() throws IOException

Overrides java.io.Reader.read.

Although this method is implemented by the base class, AND it should never be called by Woodstox code, let's still implement it bit more efficiently just in case

Returns:int

Doc from java.io.Reader.read.

The character read, as an integer in the range 0 to 65535 (0x00-0xffff), or -1 if the end of the stream has been reached

Annotations
@Override
Exceptions
IOException:

Doc from java.io.Reader.read.

If an I/O error occurs

readBytesback to summary
protected final int readBytes() throws IOException

Method for reading as many bytes from the underlying stream as possible (that fit in the buffer), to the beginning of the buffer.

readBytesAtback to summary
protected final int readBytesAt(int offset) throws IOException

Method for reading as many bytes from the underlying stream as possible (that fit in the buffer considering offset), to the specified offset.

Returns:int

Number of bytes read, if any; -1 to indicate none available (that is, end of input)

reportBoundsback to summary
protected void reportBounds(char[] cbuf, int start, int len) throws IOException
reportInvalidXml11back to summary
protected void reportInvalidXml11(int value, int bytePos, int charPos) throws IOException
reportStrangeStreamback to summary
protected void reportStrangeStream() throws IOException
setXmlCompliancyback to summary
public abstract void setXmlCompliancy(int xmlVersion)

Method that can be called to indicate the xml conformance used when reading content using this reader. Some of the character validity checks need to be done at reader level, and sometimes they depend on xml level (for example, xml 1.1 has new linefeeds and both more and less restricted characters).