proyecto
Class JavaTextPane.DocumentReader

java.lang.Object
  extended by java.io.Reader
      extended by proyecto.JavaTextPane.DocumentReader
All Implemented Interfaces:
Closeable, Readable
Enclosing class:
JavaTextPane

 class JavaTextPane.DocumentReader
extends Reader

A reader interface for an abstract document. Since the syntax highlighting packages only accept Stings and Readers, this must be used. Since the close() method does nothing and a seek() method has been added, this allows us to get some performance improvements through reuse. It can be used even after the lexer explicitly closes it by seeking to the place that we want to read next, and reseting the lexer.


Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
JavaTextPane.DocumentReader(AbstractDocument document)
          Construct a reader on the given document.
 
Method Summary
 void close()
          Has no effect.
 void mark(int readAheadLimit)
          Save a position for reset.
 boolean markSupported()
          This reader support mark and reset.
 int read()
          Read a single character.
 int read(char[] cbuf)
          Read and fill the buffer.
 int read(char[] cbuf, int off, int len)
          Read and fill the buffer.
 boolean ready()
           
 void reset()
          Reset this reader to the last mark, or the beginning of the document if a mark has not been set.
 void seek(long n)
          Seek to the given position in the document.
 long skip(long n)
          Skip characters of input.
 void update(int position, int adjustment)
          Modifying the document while the reader is working is like pulling the rug out from under the reader.
 
Methods inherited from class java.io.Reader
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaTextPane.DocumentReader

public JavaTextPane.DocumentReader(AbstractDocument document)
Construct a reader on the given document.

Parameters:
document - the document to be read.
Method Detail

update

public void update(int position,
                   int adjustment)
Modifying the document while the reader is working is like pulling the rug out from under the reader. Alerting the reader with this method (in a nice thread safe way, this should not be called at the same time as a read) allows the reader to compensate.


close

public void close()
Has no effect. This reader can be used even after it has been closed.

Specified by:
close in interface Closeable
Specified by:
close in class Reader

mark

public void mark(int readAheadLimit)
Save a position for reset.

Overrides:
mark in class Reader
Parameters:
readAheadLimit - ignored.

markSupported

public boolean markSupported()
This reader support mark and reset.

Overrides:
markSupported in class Reader
Returns:
true

read

public int read()
Read a single character.

Overrides:
read in class Reader
Returns:
the character or -1 if the end of the document has been reached.

read

public int read(char[] cbuf)
Read and fill the buffer. This method will always fill the buffer unless the end of the document is reached.

Overrides:
read in class Reader
Parameters:
cbuf - the buffer to fill.
Returns:
the number of characters read or -1 if no more characters are available in the document.

read

public int read(char[] cbuf,
                int off,
                int len)
Read and fill the buffer. This method will always fill the buffer unless the end of the document is reached.

Specified by:
read in class Reader
Parameters:
cbuf - the buffer to fill.
off - offset into the buffer to begin the fill.
len - maximum number of characters to put in the buffer.
Returns:
the number of characters read or -1 if no more characters are available in the document.

ready

public boolean ready()
Overrides:
ready in class Reader
Returns:
true

reset

public void reset()
Reset this reader to the last mark, or the beginning of the document if a mark has not been set.

Overrides:
reset in class Reader

skip

public long skip(long n)
Skip characters of input. This method will always skip the maximum number of characters unless the end of the file is reached.

Overrides:
skip in class Reader
Parameters:
n - number of characters to skip.
Returns:
the actual number of characters skipped.

seek

public void seek(long n)
Seek to the given position in the document.

Parameters:
n - the offset to which to seek.