Package org.fife.io

Class DocumentReader

java.lang.Object
java.io.Reader
org.fife.io.DocumentReader
All Implemented Interfaces:
Closeable, AutoCloseable, Readable

public class DocumentReader extends Reader
A Reader for javax.swing.text.Document objects.
Version:
1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private Document
    The document we're working on.
    private long
    A remembered position in the document.
    private long
    The stream's position in the document.
    private Segment
    Used for fast character access.

    Fields inherited from class java.io.Reader

    lock
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This currently does nothing...
    void
    mark(int readAheadLimit)
    Marks the present position in the stream.
    boolean
    Tells whether this reader supports the mark operation.
    int
    Reads the single character at the current position in the document.
    int
    read(char[] array)
    Read array.length characters from the beginning of the document into array.
    int
    read(char[] cbuf, int off, int len)
    Reads characters into a portion of an array.
    boolean
    Tells whether this reader is ready to be read without blocking for input.
    void
    Resets the stream.
    void
    seek(long pos)
    Move to the specified position in the document.
    long
    skip(long n)
    Skips characters.

    Methods inherited from class java.io.Reader

    nullReader, read, transferTo

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • position

      private long position
      The stream's position in the document.
    • mark

      private long mark
      A remembered position in the document.
    • document

      private Document document
      The document we're working on.
    • segment

      private Segment segment
      Used for fast character access.
  • Constructor Details

    • DocumentReader

      public DocumentReader(Document document)
      Constructor.
      Parameters:
      document - The document we're 'reading'.
  • Method Details

    • close

      public void close()
      This currently does nothing...
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class Reader
    • mark

      public void mark(int readAheadLimit)
      Marks the present position in the stream. Subsequent calls to reset() will reposition the stream to this point.
      Overrides:
      mark in class Reader
      Parameters:
      readAheadLimit - Ignored.
    • markSupported

      public boolean markSupported()
      Tells whether this reader supports the mark operation. This always returns true for DocumentReader.
      Overrides:
      markSupported in class Reader
    • read

      public int read()
      Reads the single character at the current position in the document.
      Overrides:
      read in class Reader
    • read

      public int read(char[] array)
      Read array.length characters from the beginning of the document into array.
      Overrides:
      read in class 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:
      read in class 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 -1 if 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. DocumentReader will always return true.
      Overrides:
      ready in class Reader
      Returns:
      true if 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:
      reset in class Reader
    • skip

      public long skip(long n)
      Skips characters. This will not 'skip' past the end of the document.
      Overrides:
      skip in class 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. If pos is 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.