mirror of https://github.com/apache/lucene.git
LUCENE-3822: Add missing methods to FilterAtomicReader inner classes.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1293821 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6cc374ce92
commit
4b9f2d3714
|
@ -17,8 +17,10 @@ package org.apache.lucene.index;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.lucene.util.AttributeSource;
|
||||
import org.apache.lucene.util.Bits;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.automaton.CompiledAutomaton;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Comparator;
|
||||
|
@ -37,7 +39,7 @@ public class FilterAtomicReader extends AtomicReader {
|
|||
/** Base class for filtering {@link Fields}
|
||||
* implementations. */
|
||||
public static class FilterFields extends Fields {
|
||||
protected Fields in;
|
||||
protected final Fields in;
|
||||
|
||||
public FilterFields(Fields in) {
|
||||
this.in = in;
|
||||
|
@ -57,12 +59,17 @@ public class FilterAtomicReader extends AtomicReader {
|
|||
public int getUniqueFieldCount() throws IOException {
|
||||
return in.getUniqueFieldCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUniqueTermCount() throws IOException {
|
||||
return in.getUniqueTermCount();
|
||||
}
|
||||
}
|
||||
|
||||
/** Base class for filtering {@link Terms}
|
||||
* implementations. */
|
||||
public static class FilterTerms extends Terms {
|
||||
protected Terms in;
|
||||
protected final Terms in;
|
||||
|
||||
public FilterTerms(Terms in) {
|
||||
this.in = in;
|
||||
|
@ -97,11 +104,16 @@ public class FilterAtomicReader extends AtomicReader {
|
|||
public int getDocCount() throws IOException {
|
||||
return in.getDocCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TermsEnum intersect(CompiledAutomaton automaton, BytesRef bytes) throws java.io.IOException {
|
||||
return in.intersect(automaton, bytes);
|
||||
}
|
||||
}
|
||||
|
||||
/** Base class for filtering {@link TermsEnum} implementations. */
|
||||
public static class FilterFieldsEnum extends FieldsEnum {
|
||||
protected FieldsEnum in;
|
||||
protected final FieldsEnum in;
|
||||
public FilterFieldsEnum(FieldsEnum in) {
|
||||
this.in = in;
|
||||
}
|
||||
|
@ -115,11 +127,16 @@ public class FilterAtomicReader extends AtomicReader {
|
|||
public Terms terms() throws IOException {
|
||||
return in.terms();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeSource attributes() {
|
||||
return in.attributes();
|
||||
}
|
||||
}
|
||||
|
||||
/** Base class for filtering {@link TermsEnum} implementations. */
|
||||
public static class FilterTermsEnum extends TermsEnum {
|
||||
protected TermsEnum in;
|
||||
protected final TermsEnum in;
|
||||
|
||||
public FilterTermsEnum(TermsEnum in) { this.in = in; }
|
||||
|
||||
|
@ -187,11 +204,16 @@ public class FilterAtomicReader extends AtomicReader {
|
|||
public TermState termState() throws IOException {
|
||||
return in.termState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeSource attributes() {
|
||||
return in.attributes();
|
||||
}
|
||||
}
|
||||
|
||||
/** Base class for filtering {@link DocsEnum} implementations. */
|
||||
public static class FilterDocsEnum extends DocsEnum {
|
||||
protected DocsEnum in;
|
||||
protected final DocsEnum in;
|
||||
|
||||
public FilterDocsEnum(DocsEnum in) {
|
||||
this.in = in;
|
||||
|
@ -216,11 +238,16 @@ public class FilterAtomicReader extends AtomicReader {
|
|||
public int advance(int target) throws IOException {
|
||||
return in.advance(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeSource attributes() {
|
||||
return in.attributes();
|
||||
}
|
||||
}
|
||||
|
||||
/** Base class for filtering {@link DocsAndPositionsEnum} implementations. */
|
||||
public static class FilterDocsAndPositionsEnum extends DocsAndPositionsEnum {
|
||||
protected DocsAndPositionsEnum in;
|
||||
protected final DocsAndPositionsEnum in;
|
||||
|
||||
public FilterDocsAndPositionsEnum(DocsAndPositionsEnum in) {
|
||||
this.in = in;
|
||||
|
@ -270,9 +297,14 @@ public class FilterAtomicReader extends AtomicReader {
|
|||
public boolean hasPayload() {
|
||||
return in.hasPayload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeSource attributes() {
|
||||
return in.attributes();
|
||||
}
|
||||
}
|
||||
|
||||
protected AtomicReader in;
|
||||
protected final AtomicReader in;
|
||||
|
||||
/**
|
||||
* <p>Construct a FilterAtomicReader based on the specified base reader.
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.apache.lucene.index;
|
|||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.TextField;
|
||||
|
@ -31,7 +29,6 @@ import org.apache.lucene.store.MockDirectoryWrapper;
|
|||
import org.apache.lucene.util.Bits;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.ReaderUtil;
|
||||
|
||||
public class TestFilterAtomicReader extends LuceneTestCase {
|
||||
|
||||
|
@ -176,22 +173,31 @@ public class TestFilterAtomicReader extends LuceneTestCase {
|
|||
directory.close();
|
||||
target.close();
|
||||
}
|
||||
|
||||
public void testOverrideMethods() throws Exception {
|
||||
|
||||
private void checkOverrideMethods(Class<?> clazz) throws Exception {
|
||||
boolean fail = false;
|
||||
for (Method m : FilterAtomicReader.class.getMethods()) {
|
||||
for (Method m : clazz.getMethods()) {
|
||||
int mods = m.getModifiers();
|
||||
if (Modifier.isStatic(mods) || Modifier.isFinal(mods) || m.isSynthetic()) {
|
||||
continue;
|
||||
}
|
||||
Class<?> declaringClass = m.getDeclaringClass();
|
||||
String name = m.getName();
|
||||
if (declaringClass != FilterAtomicReader.class && declaringClass != Object.class) {
|
||||
System.err.println("method is not overridden by FilterIndexReader: " + name);
|
||||
if (declaringClass != clazz && declaringClass != Object.class) {
|
||||
System.err.println("method is not overridden by "+clazz.getName()+": " + m.toGenericString());
|
||||
fail = true;
|
||||
}
|
||||
}
|
||||
assertFalse("FilterIndexReader overrides (or not) some problematic methods; see log above", fail);
|
||||
assertFalse(clazz.getName()+"does not override some methods; see log above", fail);
|
||||
}
|
||||
|
||||
public void testOverrideMethods() throws Exception {
|
||||
checkOverrideMethods(FilterAtomicReader.class);
|
||||
checkOverrideMethods(FilterAtomicReader.FilterFields.class);
|
||||
checkOverrideMethods(FilterAtomicReader.FilterTerms.class);
|
||||
checkOverrideMethods(FilterAtomicReader.FilterFieldsEnum.class);
|
||||
checkOverrideMethods(FilterAtomicReader.FilterTermsEnum.class);
|
||||
checkOverrideMethods(FilterAtomicReader.FilterDocsEnum.class);
|
||||
checkOverrideMethods(FilterAtomicReader.FilterDocsAndPositionsEnum.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue