Javolution 6.0.0 java
|
Public Member Functions | |
UTF8StreamReader () | |
UTF8StreamReader (int capacity) | |
UTF8StreamReader | setInput (InputStream inStream) |
boolean | ready () throws IOException |
void | close () throws IOException |
int | read () throws IOException |
int | read (char cbuf[], int off, int len) throws IOException |
void | read (Appendable dest) throws IOException |
void | reset () |
UTF8StreamReader | setInputStream (InputStream inStream) |
Private Member Functions | |
int | read2 () throws IOException |
Private Attributes | |
InputStream | _inputStream |
int | _start |
int | _end |
final byte[] | _bytes |
int | _code |
int | _moreBytes |
A UTF-8 stream reader.
This reader supports surrogate char
pairs (representing characters in the range [U+10000 .. U+10FFFF]). It can also be used to read characters unicodes (31 bits) directly (ref. read()).
Each invocation of one of the read()
methods may cause one or more bytes to be read from the underlying byte-input stream. To enable the efficient conversion of bytes to characters, more bytes may be read ahead from the underlying stream than are necessary to satisfy the current read operation.
Instances of this class can be reused for different input streams and can be part of a higher level component (e.g. parser) in order to avoid dynamic buffer allocation when the input source changes. Also wrapping using a java.io.BufferedReader
is unnescessary as instances of this class embed their own data buffers.
Note: This reader is unsynchronized and does not test if the UTF-8 encoding is well-formed (e.g. UTF-8 sequences longer than necessary to encode a character).
Definition at line 44 of file UTF8StreamReader.java.
javolution.io.UTF8StreamReader.UTF8StreamReader | ( | ) |
Creates a UTF-8 reader having a byte buffer of moderate capacity (2048).
Definition at line 69 of file UTF8StreamReader.java.
References javolution.io.UTF8StreamReader._bytes.
javolution.io.UTF8StreamReader.UTF8StreamReader | ( | int | capacity | ) |
Creates a UTF-8 reader having a byte buffer of specified capacity.
capacity | the capacity of the byte buffer. |
Definition at line 78 of file UTF8StreamReader.java.
References javolution.io.UTF8StreamReader._bytes.
void javolution.io.UTF8StreamReader.close | ( | ) | throws IOException |
Closes and resets this reader for reuse.
IOException | if an I/O error occurs. |
Definition at line 120 of file UTF8StreamReader.java.
References javolution.io.UTF8StreamReader._inputStream, and javolution.io.UTF8StreamReader.reset().
int javolution.io.UTF8StreamReader.read | ( | ) | throws IOException |
Reads a single character. This method will block until a character is available, an I/O error occurs or the end of the stream is reached.
IOException | if an I/O error occurs. |
Definition at line 135 of file UTF8StreamReader.java.
References javolution.io.UTF8StreamReader._bytes, javolution.io.UTF8StreamReader._end, javolution.io.UTF8StreamReader._start, and javolution.io.UTF8StreamReader.read2().
void javolution.io.UTF8StreamReader.read | ( | Appendable | dest | ) | throws IOException |
Reads characters into the specified appendable. This method will block until the end of the stream is reached.
dest | the destination buffer. |
IOException | if an I/O error occurs. |
Definition at line 271 of file UTF8StreamReader.java.
References javolution.io.UTF8StreamReader._bytes, javolution.io.UTF8StreamReader._end, javolution.io.UTF8StreamReader._inputStream, javolution.io.UTF8StreamReader._start, and javolution.io.UTF8StreamReader.read2().
int javolution.io.UTF8StreamReader.read | ( | char | cbuf[], |
int | off, | ||
int | len | ||
) | throws IOException |
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.
Note: Characters between U+10000 and U+10FFFF are represented by surrogate pairs (two char
).
cbuf | the destination buffer. |
off | the offset at which to start storing characters. |
len | the maximum number of characters to read |
IOException | if an I/O error occurs. |
Definition at line 222 of file UTF8StreamReader.java.
References javolution.io.UTF8StreamReader._bytes, javolution.io.UTF8StreamReader._end, javolution.io.UTF8StreamReader._inputStream, javolution.io.UTF8StreamReader._start, and javolution.io.UTF8StreamReader.read2().
|
private |
Definition at line 141 of file UTF8StreamReader.java.
References javolution.io.UTF8StreamReader._bytes, javolution.io.UTF8StreamReader._code, javolution.io.UTF8StreamReader._end, javolution.io.UTF8StreamReader._inputStream, javolution.io.UTF8StreamReader._moreBytes, and javolution.io.UTF8StreamReader._start.
Referenced by javolution.io.UTF8StreamReader.read().
boolean javolution.io.UTF8StreamReader.ready | ( | ) | throws IOException |
Indicates if this stream is ready to be read.
true
if the next read() is guaranteed not to block for input; false
otherwise. IOException | if an I/O error occurs. |
Definition at line 109 of file UTF8StreamReader.java.
References javolution.io.UTF8StreamReader._end, javolution.io.UTF8StreamReader._inputStream, and javolution.io.UTF8StreamReader._start.
void javolution.io.UTF8StreamReader.reset | ( | ) |
Definition at line 302 of file UTF8StreamReader.java.
References javolution.io.UTF8StreamReader._code, javolution.io.UTF8StreamReader._end, javolution.io.UTF8StreamReader._inputStream, javolution.io.UTF8StreamReader._moreBytes, and javolution.io.UTF8StreamReader._start.
Referenced by javolution.io.UTF8StreamReader.close(), and javolution.xml.internal.stream.XMLStreamReaderImpl.reset().
UTF8StreamReader javolution.io.UTF8StreamReader.setInput | ( | InputStream | inStream | ) |
Sets the input stream to use for reading until this reader is closed. For example:[code] Reader reader = new UTF8StreamReader().setInput(inStream); [/code] is equivalent but reads twice as fast as [code] Reader reader = new java.io.InputStreamReader(inStream, "UTF-8"); [/code]
inStream | the input stream. |
Definition at line 95 of file UTF8StreamReader.java.
References javolution.io.UTF8StreamReader._inputStream.
Referenced by javolution.xml.internal.stream.XMLStreamReaderImpl.setInput(), and javolution.io.UTF8StreamReader.setInputStream().
UTF8StreamReader javolution.io.UTF8StreamReader.setInputStream | ( | InputStream | inStream | ) |
Definition at line 313 of file UTF8StreamReader.java.
References javolution.io.UTF8StreamReader.setInput().
|
private |
Holds the bytes buffer.
Definition at line 64 of file UTF8StreamReader.java.
Referenced by javolution.io.UTF8StreamReader.read(), javolution.io.UTF8StreamReader.read2(), and javolution.io.UTF8StreamReader.UTF8StreamReader().
|
private |
Definition at line 203 of file UTF8StreamReader.java.
Referenced by javolution.io.UTF8StreamReader.read2(), and javolution.io.UTF8StreamReader.reset().
|
private |
Holds the end index.
Definition at line 59 of file UTF8StreamReader.java.
Referenced by javolution.io.UTF8StreamReader.read(), javolution.io.UTF8StreamReader.read2(), javolution.io.UTF8StreamReader.ready(), and javolution.io.UTF8StreamReader.reset().
|
private |
Holds the current input stream or null
if closed.
Definition at line 49 of file UTF8StreamReader.java.
Referenced by javolution.io.UTF8StreamReader.close(), javolution.io.UTF8StreamReader.read(), javolution.io.UTF8StreamReader.read2(), javolution.io.UTF8StreamReader.ready(), javolution.io.UTF8StreamReader.reset(), and javolution.io.UTF8StreamReader.setInput().
|
private |
Definition at line 205 of file UTF8StreamReader.java.
Referenced by javolution.io.UTF8StreamReader.read2(), and javolution.io.UTF8StreamReader.reset().
|
private |
Holds the start index.
Definition at line 54 of file UTF8StreamReader.java.
Referenced by javolution.io.UTF8StreamReader.read(), javolution.io.UTF8StreamReader.read2(), javolution.io.UTF8StreamReader.ready(), and javolution.io.UTF8StreamReader.reset().