| java.lang.Object java.io.Reader com.opensymphony.module.sitemesh.util.CharArrayReader
CharArrayReader | public class CharArrayReader extends Reader (Code) | | This class implements a character buffer that can be used as a
character-input stream.
Modified from the JDK source in that it gets rid of the
ensureOpen() method, so we get unexpected behaviour if the
reader is closed.
The second modification is that since this class is used
internally by FastPageParser in a single thread, we don't
need any locking or synchronization. Using this class
instead of the standard CharArrayReader improves
FastPageParser performance by 15-20%.
author: Hani Suleiman |
Field Summary | |
protected char | buf The character buffer. | protected int | count The index of the end of this buffer. | protected int | markedPos The position of mark in buffer. | protected int | pos The current buffer position. |
Constructor Summary | |
public | CharArrayReader(char buf) Create an CharArrayReader from the specified array of chars. | public | CharArrayReader(char buf, int offset, int length) Create an CharArrayReader from the specified array of chars. |
Method Summary | |
public void | close() Close the stream. | public void | mark(int readAheadLimit) Mark the present position in the stream. | public boolean | markSupported() Tell whether this stream supports the mark() operation, which it does. | public int | read() Read a single character. | public int | read(char b, int off, int len) Read characters into a portion of an array. | public boolean | ready() Tell whether this stream is ready to be read. | public void | reset() Reset the stream to the most recent mark, or to the beginning if it has
never been marked. | public long | skip(long n) Skip characters. |
buf | protected char buf(Code) | | The character buffer.
|
count | protected int count(Code) | | The index of the end of this buffer. There is not valid
data at or beyond this index.
|
markedPos | protected int markedPos(Code) | | The position of mark in buffer.
|
pos | protected int pos(Code) | | The current buffer position.
|
CharArrayReader | public CharArrayReader(char buf)(Code) | | Create an CharArrayReader from the specified array of chars.
Parameters: buf - Input buffer (not copied) |
CharArrayReader | public CharArrayReader(char buf, int offset, int length)(Code) | | Create an CharArrayReader from the specified array of chars.
Parameters: buf - Input buffer (not copied) Parameters: offset - Offset of the first char to read Parameters: length - Number of chars to read |
close | public void close()(Code) | | Close the stream.
|
mark | public void mark(int readAheadLimit) throws IOException(Code) | | Mark the present position in the stream. Subsequent calls to reset()
will reposition the stream to this point.
Parameters: readAheadLimit - Limit on the number of characters that may beread while still preserving the mark. Becausethe stream's input comes from a character array,there is no actual limit; hence this argument isignored. throws: IOException - If an I/O error occurs |
markSupported | public boolean markSupported()(Code) | | Tell whether this stream supports the mark() operation, which it does.
|
read | public int read(char b, int off, int len) throws IOException(Code) | | Read characters into a portion of an array.
Parameters: b - Destination buffer Parameters: off - Offset at which to start storing characters Parameters: len - Maximum number of characters to read The actual number of characters read, or -1 ifthe end of the stream has been reached throws: IOException - If an I/O error occurs |
ready | public boolean ready() throws IOException(Code) | | Tell whether this stream is ready to be read. Character-array readers
are always ready to be read.
throws: IOException - If an I/O error occurs |
reset | public void reset() throws IOException(Code) | | Reset the stream to the most recent mark, or to the beginning if it has
never been marked.
throws: IOException - If an I/O error occurs |
skip | public long skip(long n) throws IOException(Code) | | Skip characters.
Parameters: n - The number of characters to skip throws: IOException - If an I/O error occurs The number of characters actually skipped |
|
|