info.aduna.io
Class CharPosReader

java.lang.Object
  extended by java.io.Reader
      extended by info.aduna.io.CharPosReader
All Implemented Interfaces:
Closeable, Readable

public class CharPosReader
extends Reader

A character-stream reader that registers the position of the next character to read. This position can be a character offset or a combination of a line and column number. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r') , or a carriage return followed immediately by a linefeed ('\r\n').


Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
CharPosReader(Reader r)
          Creates a new CharPosReader.
 
Method Summary
 void close()
           
 int getCharPos()
          Get the character position (1-based) for the next character to read.
 int getColumn()
          Get the column (1-based) for the next character to read.
 int getLineNo()
          Get the line number (1-based) for the next character to read.
 int read()
           
 int read(char[] cbuf, int off, int len)
           
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CharPosReader

public CharPosReader(Reader r)
Creates a new CharPosReader.

Method Detail

getLineNo

public int getLineNo()
Get the line number (1-based) for the next character to read.


getColumn

public int getColumn()
Get the column (1-based) for the next character to read.


getCharPos

public int getCharPos()
Get the character position (1-based) for the next character to read.


read

public int read()
         throws IOException
Overrides:
read in class Reader
Throws:
IOException

read

public int read(char[] cbuf,
                int off,
                int len)
         throws IOException
Specified by:
read in class Reader
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in class Reader
Throws:
IOException


Copyright © 2011 Aduna. All Rights Reserved.