echopoint.ui.template
Class PositionReader

java.lang.Object
  extended by java.io.Reader
      extended by echopoint.ui.template.PositionReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class PositionReader
extends java.io.Reader

A PositionReader can be asked for the current position in the stream as well as the current logical line number.


Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
PositionReader(java.io.Reader r)
          Constructs a PositionReader based on a source Reader
 
Method Summary
 void close()
           
 long getLineNumber()
          Get the current line number.
 long getPosition()
          Returns the current position within the file
 java.io.Reader getReader()
          Returns the underlying Reader
 void mark(int readAheadLimit)
           
 boolean markSupported()
           
 int read()
          Read a single character.
 int read(char[] cbuff)
           
 int read(char[] cbuff, int off, int len)
          Read characters into a portion of an array.
 boolean ready()
           
 void reset()
           
 void setLineNumber(int lineNumber)
          Set the current line number.
 long skip(long n)
           
 java.lang.String toString()
           
 
Methods inherited from class java.io.Reader
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PositionReader

public PositionReader(java.io.Reader r)
Constructs a PositionReader based on a source Reader

Parameters:
r - the Reader to actually read from
Method Detail

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Reader
Throws:
java.io.IOException
See Also:
Reader.close()

getLineNumber

public long getLineNumber()
Get the current line number.

Returns:
The current line number.
See Also:
setLineNumber(int)

getPosition

public long getPosition()
Returns the current position within the file

Returns:
the current position within the file

mark

public void mark(int readAheadLimit)
          throws java.io.IOException
Overrides:
mark in class java.io.Reader
Throws:
java.io.IOException
See Also:
Reader.mark(int)

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.Reader
See Also:
Reader.markSupported()

read

public int read()
         throws java.io.IOException
Read a single character.

Overrides:
read in class java.io.Reader
Returns:
The character read, or -1 if the end of the stream has been reached
Throws:
java.io.IOException - If an I/O error occurs

read

public int read(char[] cbuff,
                int off,
                int len)
         throws java.io.IOException
Read characters into a portion of an array.

Specified by:
read in class java.io.Reader
Parameters:
cbuff - Destination buffer
off - Offset at which to start storing characters
len - Maximum number of characters to read
Returns:
The number of bytes read, or -1 if the end of the stream has already been reached
Throws:
java.io.IOException - If an I/O error occurs

read

public int read(char[] cbuff)
         throws java.io.IOException
Overrides:
read in class java.io.Reader
Throws:
java.io.IOException
See Also:
Reader.read(char[])

ready

public boolean ready()
              throws java.io.IOException
Overrides:
ready in class java.io.Reader
Throws:
java.io.IOException
See Also:
Reader.ready()

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class java.io.Reader
Throws:
java.io.IOException
See Also:
Reader.reset()

setLineNumber

public void setLineNumber(int lineNumber)
Set the current line number.

Parameters:
lineNumber - an int specifying the line number.
See Also:
getLineNumber()

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.Reader
Throws:
java.io.IOException
See Also:
Reader.skip(long)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

getReader

public java.io.Reader getReader()
Returns the underlying Reader

Returns:
the underlying Reader