mirror of https://github.com/apache/lucene.git
LUCENE-1734: CharReader should delegate reset/mark/markSupported
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@791415 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7acabfecf0
commit
6a3752feb8
|
@ -58,4 +58,16 @@ public abstract class CharFilter extends CharStream {
|
||||||
public int read(char[] cbuf, int off, int len) throws IOException {
|
public int read(char[] cbuf, int off, int len) throws IOException {
|
||||||
return input.read(cbuf, off, len);
|
return input.read(cbuf, off, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean markSupported(){
|
||||||
|
return input.markSupported();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mark( int readAheadLimit ) throws IOException {
|
||||||
|
input.mark(readAheadLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() throws IOException {
|
||||||
|
input.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,4 +50,16 @@ public final class CharReader extends CharStream {
|
||||||
public int read(char[] cbuf, int off, int len) throws IOException {
|
public int read(char[] cbuf, int off, int len) throws IOException {
|
||||||
return input.read(cbuf, off, len);
|
return input.read(cbuf, off, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean markSupported(){
|
||||||
|
return input.markSupported();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mark( int readAheadLimit ) throws IOException {
|
||||||
|
input.mark(readAheadLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() throws IOException {
|
||||||
|
input.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,16 +125,4 @@ public class MappingCharFilter extends BaseCharFilter {
|
||||||
}
|
}
|
||||||
return l == 0 ? -1 : l;
|
return l == 0 ? -1 : l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean markSupported() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mark(int readAheadLimit) throws IOException {
|
|
||||||
throw new IOException("mark/reset not supported");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset() throws IOException {
|
|
||||||
throw new IOException("mark/reset not supported");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,22 @@ public class TestMappingCharFilter extends BaseTokenTestCase {
|
||||||
normMap.add( "empty", "" );
|
normMap.add( "empty", "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testReaderReset() throws Exception {
|
||||||
|
CharStream cs = new MappingCharFilter( normMap, CharReader.get( new StringReader( "x" ) ) );
|
||||||
|
char[] buf = new char[10];
|
||||||
|
int len = cs.read(buf, 0, 10);
|
||||||
|
assertEquals( 1, len );
|
||||||
|
assertEquals( 'x', buf[0]) ;
|
||||||
|
len = cs.read(buf, 0, 10);
|
||||||
|
assertEquals( -1, len );
|
||||||
|
|
||||||
|
// rewind
|
||||||
|
cs.reset();
|
||||||
|
len = cs.read(buf, 0, 10);
|
||||||
|
assertEquals( 1, len );
|
||||||
|
assertEquals( 'x', buf[0]) ;
|
||||||
|
}
|
||||||
|
|
||||||
public void testNothingChange() throws Exception {
|
public void testNothingChange() throws Exception {
|
||||||
CharStream cs = new MappingCharFilter( normMap, CharReader.get( new StringReader( "x" ) ) );
|
CharStream cs = new MappingCharFilter( normMap, CharReader.get( new StringReader( "x" ) ) );
|
||||||
TokenStream ts = new WhitespaceTokenizer( cs );
|
TokenStream ts = new WhitespaceTokenizer( cs );
|
||||||
|
|
Loading…
Reference in New Issue