Package de.intarsys.tools.reader
Class LocationAwareReader
java.lang.Object
java.io.Reader
java.io.FilterReader
de.intarsys.tools.reader.LocationAwareReader
- All Implemented Interfaces:
ILocationProvider
,Closeable
,AutoCloseable
,Readable
An implementation of ILocationProvider. This class can be "piped" in a reader
stream to access the current "pointer" into the data.
A common pitfall is to read the ILocationProvider via a BufferedReader - this will certainly not provide with a correct character location!
-
Field Summary
Fields inherited from class java.io.FilterReader
in
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
int
int
getLine()
int
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) Methods inherited from class java.io.FilterReader
mark, markSupported, ready, reset
Methods inherited from class java.io.Reader
nullReader, read, read, transferTo
-
Constructor Details
-
LocationAwareReader
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterReader
- Throws:
IOException
-
ensureOpen
- Throws:
IOException
-
getColumn
public int getColumn()- Specified by:
getColumn
in interfaceILocationProvider
-
getLine
public int getLine()- Specified by:
getLine
in interfaceILocationProvider
-
getPosition
public int getPosition()- Specified by:
getPosition
in interfaceILocationProvider
-
read
- Overrides:
read
in classFilterReader
- Throws:
IOException
-
read
- Overrides:
read
in classFilterReader
- Throws:
IOException
-
setColumn
public void setColumn(int column) - Parameters:
column
- The column to set.
-
setLine
public void setLine(int line) - Parameters:
line
- The line to set.
-
setLocation
public void setLocation(int line, int column) Offset the current location to a user defined line and column.- Parameters:
line
- The line we want the reader to accept as new locationcolumn
- The column we want the reader to accept as new location
-
setPosition
public void setPosition(int position) - Parameters:
position
- The position to set.
-
skip
- Overrides:
skip
in classFilterReader
- Throws:
IOException
-