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

public final Class AsciiReader

extends BaseReader
Class Inheritance
Imports
java.io.*, com.ctc.wstx.api.ReaderConfig, com.ctc.wstx.cfg.XmlConsts

Optimized Reader that reads ascii content from an input stream. In addition to doing (hopefully) optimal conversion, it can also take array of "pre-read" (leftover) bytes; this is necessary when preliminary stream/reader is trying to figure out XML encoding.

Field Summary

Modifier and TypeField and Description
pack-priv int
mCharCount

Total read character count; used for error reporting purposes (note: byte count is the same, due to fixed one-byte-per char mapping)

pack-priv boolean
Inherited from com.ctc.wstx.io.BaseReader:
CHAR_DELCONVERT_LSEP_TOCONVERT_NEL_TOmByteBuffermByteBufferEndmBytePtrmConfigmTmpBufNULL_BYTENULL_CHAR

Constructor Summary

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

Method Summary

Modifier and TypeMethod and Description
public int
read(char[]
Destination buffer
cbuf
,
int
Offset at which to start storing characters
start
,
int
Maximum number of characters to read
len
)

Implements abstract java.io.Reader.read.

Reads characters into a portion of an array.

private void
public void
setXmlCompliancy(int xmlVersion)

Implements abstract com.ctc.wstx.io.BaseReader.setXmlCompliancy.

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

Inherited from com.ctc.wstx.io.BaseReader:
canModifyBufferclosefreeBuffersgetStreamreadreadBytesreadBytesAtreportBoundsreportInvalidXml11reportStrangeStream

Field Detail

mCharCountback to summary
pack-priv int mCharCount

Total read character count; used for error reporting purposes (note: byte count is the same, due to fixed one-byte-per char mapping)

mXml11back to summary
pack-priv boolean mXml11

Constructor Detail

AsciiReaderback to summary
public AsciiReader(ReaderConfig cfg, InputStream in, byte[] buf, int ptr, int len, boolean recycleBuffer)

Method Detail

readback to summary
public int read(char[] cbuf, int start, int len) throws IOException

Implements abstract java.io.Reader.read.

Doc from java.io.Reader.read.

Reads characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

If len is zero, then no characters are read and 0 is returned; otherwise, there is an attempt to read at least one character. If no character is available because the stream is at its end, the value -1 is returned; otherwise, at least one character is read and stored into cbuf.

Parameters
cbuf:char[]

Destination buffer

start:int

Offset at which to start storing characters

len:int

Maximum number of characters to read

Returns:int

The number of characters read, or -1 if the end of the stream has been reached

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
reportInvalidAsciiback to summary
private void reportInvalidAscii(char c) throws IOException
setXmlCompliancyback to summary
public void setXmlCompliancy(int xmlVersion)

Implements abstract com.ctc.wstx.io.BaseReader.setXmlCompliancy.

Doc from com.ctc.wstx.io.BaseReader.setXmlCompliancy.

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).

Annotations
@Override