public class LocationAwareReader extends java.io.FilterReader implements ILocationProvider
A common pitfall is to read the ILocationProvider via a BufferedReader - this will certainly not provide with a correct character location!
Constructor and Description |
---|
LocationAwareReader(java.io.Reader in) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
ensureOpen() |
int |
getColumn() |
int |
getLine() |
int |
getPosition() |
int |
read() |
int |
read(char[] cbuf,
int off,
int len) |
void |
setColumn(int column) |
void |
setLine(int line) |
void |
setLocation(int line,
int column)
Offset the current location to a user defined line and column.
|
void |
setPosition(int position) |
long |
skip(long n) |
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.FilterReader
java.io.IOException
public void ensureOpen() throws java.io.IOException
java.io.IOException
public int getColumn()
getColumn
in interface ILocationProvider
public int getLine()
getLine
in interface ILocationProvider
public int getPosition()
getPosition
in interface ILocationProvider
public int read() throws java.io.IOException
read
in class java.io.FilterReader
java.io.IOException
public int read(char[] cbuf, int off, int len) throws java.io.IOException
read
in class java.io.FilterReader
java.io.IOException
public void setColumn(int column)
column
- The column to set.public void setLine(int line)
line
- The line to set.public void setLocation(int line, int column)
line
- The line we want the reader to accept as new locationcolumn
- The column we want the reader to accept as new locationpublic void setPosition(int position)
position
- The position to set.public long skip(long n) throws java.io.IOException
skip
in class java.io.FilterReader
java.io.IOException