2 * Copyright (c) 1995-2012, Index Data
4 * See the file LICENSE for details.
6 package org.z3950.zing.cql;
8 import java.io.IOException;
10 import java.nio.CharBuffer;
13 * Reader proxy to count how many characters has been read so far.
16 public class PositionAwareReader extends Reader {
17 protected Reader reader;
18 protected int pos = -1;
20 public PositionAwareReader(Reader reader) {
25 * Position of the last read character or -1 if either reading from an empty
26 * stream or no 'read' has been invoked for this reader.
28 public int getPosition() {
33 public void mark(int readAheadLimit) throws IOException {
34 reader.mark(readAheadLimit);
38 public boolean markSupported() {
39 return reader.markSupported();
43 public int read() throws IOException {
44 int c = reader.read();
50 public int read(char[] cbuf) throws IOException {
51 int c = reader.read(cbuf);
57 public int read(CharBuffer target) throws IOException {
58 int c = reader.read(target);
64 public int read(char[] cbuf, int off, int len) throws IOException {
65 int c = reader.read(cbuf, off, len);
71 public boolean ready() throws IOException {
72 return reader.ready();
76 public long skip(long n) throws IOException {
77 return reader.skip(n);
81 public void close() throws IOException {
86 public void reset() throws IOException {
90 //override object methods, to be on the safe-side
93 public boolean equals(Object obj) {
94 return reader.equals(obj);
98 public String toString() {
99 return reader.toString();
103 public int hashCode() {
104 return reader.hashCode();