|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.Reader
com.cburch.editor.util.DocumentReader
public class DocumentReader
A reader interface for a document. This is intended to be used where a existing code expects a Reader, but we have a Document.
The particular application it was design for is in tokenizing a Document: JFlex-generated code depends on fetching tokens from a Reader, but in our case we want to fetch tokens from a Document.
| Constructor Summary | |
|---|---|
DocumentReader(javax.swing.text.Document document)
Constructs a reader for the given document. |
|
| Method Summary | |
|---|---|
void |
close()
Does nothing. |
javax.swing.text.Document |
getDocument()
Returns the document underlying this DocumentReader. |
void |
mark(int readAheadLimit)
Saves the current position for reset. |
boolean |
markSupported()
Returns true, since this reader supports
mark and reset. |
int |
read()
Reads a single character and advances the internal cursor one step forward. |
int |
read(char[] cbuf)
Reads and fills the given buffer. |
int |
read(char[] cbuf,
int off,
int len)
Reads and fills the buffer. |
boolean |
ready()
Returns true since the Document is always
available for reading. |
void |
reset()
Resets this reader to the last mark, or to the document's beginning if a mark has not been set. |
void |
seek(long n)
Seeks to the given position in the document. |
long |
skip(long n)
Skips past characters in the document. |
| Methods inherited from class java.io.Reader |
|---|
read |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DocumentReader(javax.swing.text.Document document)
document - the document to be read.| Method Detail |
|---|
public javax.swing.text.Document getDocument()
public void close()
seek, we can
still use this Reader after the close. (It does
reset the mark, however, so that a subsequent reset
will go to the document's beginning.)
close in interface java.io.Closeableclose in class java.io.Readerpublic void mark(int readAheadLimit)
reset.
mark in class java.io.ReaderreadAheadLimit - ignored.public boolean markSupported()
true, since this reader supports
mark and reset.
markSupported in class java.io.Readertrue.public int read()
read in class java.io.Readerpublic int read(char[] cbuf)
read in class java.io.Readercbuf - the buffer to fill.
public int read(char[] cbuf,
int off,
int len)
read in class java.io.Readercbuf - the buffer to fill.off - offset into the buffer to begin the fill.len - maximum number of characters to put in the buffer.
public boolean ready()
true since the Document is always
available for reading.
ready in class java.io.Readertrue.public void reset()
reset in class java.io.Readerpublic long skip(long n)
skip in class java.io.Readern - maximum number of characters to skip.
public void seek(long n)
n - the offset to which to seek.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||