lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r791415 - in /lucene/java/trunk/src: java/org/apache/lucene/analysis/ test/org/apache/lucene/analysis/
Date Mon, 06 Jul 2009 08:55:52 GMT
Author: uschindler
Date: Mon Jul  6 08:55:52 2009
New Revision: 791415

URL: http://svn.apache.org/viewvc?rev=791415&view=rev
Log:
LUCENE-1734: CharReader should delegate reset/mark/markSupported

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/analysis/CharFilter.java
    lucene/java/trunk/src/java/org/apache/lucene/analysis/CharReader.java
    lucene/java/trunk/src/java/org/apache/lucene/analysis/MappingCharFilter.java
    lucene/java/trunk/src/test/org/apache/lucene/analysis/TestMappingCharFilter.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/CharFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/CharFilter.java?rev=791415&r1=791414&r2=791415&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/CharFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/CharFilter.java Mon Jul  6 08:55:52
2009
@@ -58,4 +58,16 @@
   public int read(char[] cbuf, int off, int len) throws IOException {
     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();
+  }
 }

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/CharReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/CharReader.java?rev=791415&r1=791414&r2=791415&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/CharReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/CharReader.java Mon Jul  6 08:55:52
2009
@@ -50,4 +50,16 @@
   public int read(char[] cbuf, int off, int len) throws IOException {
     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();
+  }
 }

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/MappingCharFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/MappingCharFilter.java?rev=791415&r1=791414&r2=791415&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/MappingCharFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/MappingCharFilter.java Mon Jul 
6 08:55:52 2009
@@ -125,16 +125,4 @@
     }
     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");
-  }
 }

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestMappingCharFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestMappingCharFilter.java?rev=791415&r1=791414&r2=791415&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestMappingCharFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestMappingCharFilter.java Mon Jul
 6 08:55:52 2009
@@ -40,6 +40,22 @@
     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 {
     CharStream cs = new MappingCharFilter( normMap, CharReader.get( new StringReader( "x"
) ) );
     TokenStream ts = new WhitespaceTokenizer( cs );



Mime
View raw message