Modifier and Type | Class and Description |
---|---|
class |
AdvancedReader.CommentHandler
Called by read method to allow comment handling.
|
Modifier and Type | Field and Description |
---|---|
protected Reader |
in
The underlying character-input stream.
|
protected Object |
lock |
Constructor and Description |
---|
AdvancedReader(Reader in)
Create a new pushback reader with a 512 characters pushback buffer.
|
AdvancedReader(Reader in,
int size)
Create a new pushback reader with a pushback buffer of the given size.
|
Modifier and Type | Method and Description |
---|---|
void |
clear(int n)
Clear n characters that can be unread (the oldest ones).
|
void |
clearAll()
Clear all characters that can be unread.
|
void |
clearLast(int n)
Clear n characters that can be unread (the newer ones).
|
void |
close()
Close the stream.
|
int |
countToMark(int mark)
Counts characters between current position and specified mark.
|
int |
getAtMark(int mark) |
int |
getColumnNumber() |
int |
getColumnNumberAtMark(int mark) |
AdvancedReader.CommentHandler |
getCommentHandler()
Retrieves comment handler
|
int |
getLineNumber() |
int |
getLineNumberAtMark(int mark) |
int |
getMaxReadLen()
Maximum number of characters to read from underlying reader
|
boolean |
isAtEnd()
Tells if there is no more charater to read from this reader.
|
boolean |
isAtMark(int startMark) |
void |
mark(int readAheadLimit)
Mark the present position in the stream.
|
boolean |
markSupported()
Tell whether this stream supports the mark() operation, which it does
not.
|
int |
putMark()
Puts an internal mark in order to be able to return to the current stream position.
|
int |
read()
Read a single character.
|
int |
read(char[] cbuf)
Read characters into an array.
|
int |
read(char[] cbuf,
int off,
int len)
Read characters into a portion of an array.
|
int |
read(CharBuffer target)
Attempts to read characters into the specified character buffer.
|
int |
readFromCache()
Read a single character, but will not access the underlying reader.
|
char[] |
readFromMark(int mark)
Reads from specified mark until current position.
|
boolean |
readUntil(Appendable builder,
CharDetector endDetector)
Reads source into builder until end char is detected or EOF is encountered.
|
char[] |
readUntilMark(int mark)
Reads from current position until specified mark.
|
boolean |
ready()
Tell whether this stream is ready to be read.
|
void |
reset()
Reset the stream.
|
boolean |
returnToMark(int mark)
Returns to the position marked by this mark ID.
|
void |
setCommentHandler(AdvancedReader.CommentHandler commentHandler)
Specifies a comment handler
|
void |
setMaxReadLen(int maxReadLen)
Specifies maximum number of characters to read from underlying reader
|
long |
skip(long n)
Skip characters, which are not possible to unread.
|
long |
skip(long n,
boolean keep)
Skip characters.
|
int |
unread()
Unread one character and return it.
|
void |
unread(int n)
Unreads n characters.
|
void |
unreadAll()
Unread all characters since last clear.
|
boolean |
unreadUntil(StringBuilder builder,
CharDetector endDetector)
Reads source into builder until end char is detected or SOF (Start Of File) is encountered.
|
protected Object lock
protected Reader in
public AdvancedReader(Reader in, int size)
in
- The reader from which characters will be readsize
- The size of the pushback bufferIllegalArgumentException
- if size is <= 0public AdvancedReader(Reader in)
in
- The reader from which characters will be readpublic int putMark() throws IOException
IOException
- Because in some cases, the next character must be read from underlying reader.public boolean isAtMark(int startMark)
public boolean returnToMark(int mark)
mark
- Mark IDpublic int countToMark(int mark)
mark
- Mark IDpublic char[] readFromMark(int mark)
mark
- Mark IDpublic char[] readUntilMark(int mark)
mark
- Mark IDpublic int readFromCache() throws IOException
IOException
- If an I/O error occurspublic int read() throws IOException
IOException
- If an I/O error occurspublic int read(CharBuffer target) throws IOException
read
in interface Readable
target
- the buffer to read characters intoIOException
- if an I/O error occursNullPointerException
- if target is nullReadOnlyBufferException
- if target is a read only bufferpublic int read(char[] cbuf) throws IOException
cbuf
- Destination bufferIOException
- If an I/O error occurspublic int read(char[] cbuf, int off, int len) throws IOException
cbuf
- Destination bufferoff
- Offset at which to start writing characterslen
- Maximum number of characters to readIOException
- If an I/O error occurspublic boolean isAtEnd() throws IOException
IOException
public int unread() throws IOException
IOException
public void unread(int n) throws IOException
n
- The number of characters to unreadIOException
- If I/O error occurspublic void unreadAll() throws IOException
IOException
- If I/O error occurspublic void clear(int n) throws IOException
n
- The number of characters to clearIOException
- If I/O error occurspublic void clearLast(int n) throws IOException
n
- The number of characters to clearIOException
- If I/O error occurspublic void clearAll() throws IOException
IOException
- If I/O error occurspublic boolean ready() throws IOException
IOException
- If an I/O error occurspublic void mark(int readAheadLimit) throws IOException
mark
for class AdvancedReader
always throws an exception.IOException
- Always, since mark is not supportedpublic void reset() throws IOException
reset
method of
AdvancedReader
always throws an exception.IOException
- Always, since reset is not supportedpublic boolean markSupported()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
- If an I/O error occurspublic long skip(long n) throws IOException
n
- The number of characters to skipIllegalArgumentException
- If n
is negative.IOException
- If an I/O error occurspublic long skip(long n, boolean keep) throws IOException
n
- The number of characters to skipkeep
- Tells if the characters should be available for unreadIllegalArgumentException
- If n
is negative.IOException
- If an I/O error occurspublic int getLineNumber()
public int getColumnNumber()
public int getAtMark(int mark)
public int getLineNumberAtMark(int mark)
public int getColumnNumberAtMark(int mark)
public boolean readUntil(Appendable builder, CharDetector endDetector) throws IOException
IOException
public boolean unreadUntil(StringBuilder builder, CharDetector endDetector) throws IOException
IOException
public AdvancedReader.CommentHandler getCommentHandler()
public void setCommentHandler(AdvancedReader.CommentHandler commentHandler)
public int getMaxReadLen()
public void setMaxReadLen(int maxReadLen)