Package org.fife.io
Class DocumentReader
- java.lang.Object
-
- java.io.Reader
-
- org.fife.io.DocumentReader
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Readable
public class DocumentReader extends java.io.ReaderAReaderforjavax.swing.text.Documentobjects.- Version:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description private javax.swing.text.DocumentdocumentThe document we're working on.private longmarkA remembered position in the document.private longpositionThe stream's position in the document.private javax.swing.text.SegmentsegmentUsed for fast character access.
-
Constructor Summary
Constructors Constructor Description DocumentReader(javax.swing.text.Document document)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()This currently does nothing...voidmark(int readAheadLimit)Marks the present position in the stream.booleanmarkSupported()Tells whether this reader supports themarkoperation.intread()Reads the single character at the current position in the document.intread(char[] array)Readarray.lengthcharacters from the beginning of the document intoarray.intread(char[] cbuf, int off, int len)Reads characters into a portion of an array.booleanready()Tells whether this reader is ready to be read without blocking for input.voidreset()Resets the stream.voidseek(long pos)Move to the specified position in the document.longskip(long n)Skips characters.
-
-
-
Field Detail
-
position
private long position
The stream's position in the document.
-
mark
private long mark
A remembered position in the document.
-
document
private javax.swing.text.Document document
The document we're working on.
-
segment
private javax.swing.text.Segment segment
Used for fast character access.
-
-
Method Detail
-
close
public void close()
This currently does nothing...- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classjava.io.Reader
-
mark
public void mark(int readAheadLimit)
Marks the present position in the stream. Subsequent calls toreset()will reposition the stream to this point.- Overrides:
markin classjava.io.Reader- Parameters:
readAheadLimit- Ignored.
-
markSupported
public boolean markSupported()
Tells whether this reader supports themarkoperation. This always returnstrueforDocumentReader.- Overrides:
markSupportedin classjava.io.Reader
-
read
public int read()
Reads the single character at the current position in the document.- Overrides:
readin classjava.io.Reader
-
read
public int read(char[] array)
Readarray.lengthcharacters from the beginning of the document intoarray.- Overrides:
readin classjava.io.Reader- Parameters:
array- The array to read characters into.- Returns:
- The number of characters read.
-
read
public int read(char[] cbuf, int off, int len)Reads characters into a portion of an array.- Specified by:
readin classjava.io.Reader- Parameters:
cbuf- The destination buffer.off- Offset at which to start storing characters.len- Maximum number of characters to read.- Returns:
- The number of characters read, or
-1if the end of the stream (document) has been reached.
-
ready
public boolean ready()
Tells whether this reader is ready to be read without blocking for input.DocumentReaderwill always return true.- Overrides:
readyin classjava.io.Reader- Returns:
trueif the next read operation will return without blocking.
-
reset
public void reset()
Resets the stream. If the stream has been marked, then attempt to reposition it at the mark. If the stream has not been marked, then move it to the beginning of the document.- Overrides:
resetin classjava.io.Reader
-
skip
public long skip(long n)
Skips characters. This will not 'skip' past the end of the document.- Overrides:
skipin classjava.io.Reader- Parameters:
n- The number of characters to skip.- Returns:
- The number of characters actually skipped.
-
seek
public void seek(long pos)
Move to the specified position in the document. Ifposis greater than the document's length, the stream's position is moved to the end of the document.- Parameters:
pos- The position in the document to move to.
-
-