EchoPoint
1.0

echopoint.ui.template
Class PositionReader

java.lang.Object
  extended byjava.io.Reader
      extended byechopoint.ui.template.PositionReader

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.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
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
Throws:
java.io.IOException
See Also:
Reader.mark(int)

markSupported

public boolean markSupported()
See Also:
Reader.markSupported()

read

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

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.

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
Throws:
java.io.IOException
See Also:
Reader.read(char[])

ready

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

reset

public void reset()
           throws java.io.IOException
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
Throws:
java.io.IOException
See Also:
Reader.skip(long)

toString

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

getReader

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

Returns:
the underlying Reader

EchoPoint
1.0