1 package org.apache.lucene.index; 2 3 18 19 import org.apache.lucene.document.Document; 20 import org.apache.lucene.document.Field; 21 22 import java.io.IOException ; 23 import java.util.Collection ; 24 25 34 public class FilterIndexReader extends IndexReader { 35 36 37 public static class FilterTermDocs implements TermDocs { 38 protected TermDocs in; 39 40 public FilterTermDocs(TermDocs in) { this.in = in; } 41 42 public void seek(Term term) throws IOException { in.seek(term); } 43 public void seek(TermEnum termEnum) throws IOException { in.seek(termEnum); } 44 public int doc() { return in.doc(); } 45 public int freq() { return in.freq(); } 46 public boolean next() throws IOException { return in.next(); } 47 public int read(int[] docs, int[] freqs) throws IOException { 48 return in.read(docs, freqs); 49 } 50 public boolean skipTo(int i) throws IOException { return in.skipTo(i); } 51 public void close() throws IOException { in.close(); } 52 } 53 54 55 public static class FilterTermPositions 56 extends FilterTermDocs implements TermPositions { 57 58 public FilterTermPositions(TermPositions in) { super(in); } 59 60 public int nextPosition() throws IOException { 61 return ((TermPositions) this.in).nextPosition(); 62 } 63 } 64 65 66 public static class FilterTermEnum extends TermEnum { 67 protected TermEnum in; 68 69 public FilterTermEnum(TermEnum in) { this.in = in; } 70 71 public boolean next() throws IOException { return in.next(); } 72 public Term term() { return in.term(); } 73 public int docFreq() { return in.docFreq(); } 74 public void close() throws IOException { in.close(); } 75 } 76 77 protected IndexReader in; 78 79 86 public FilterIndexReader(IndexReader in) { 87 super(in.directory()); 88 this.in = in; 89 } 90 91 public TermFreqVector[] getTermFreqVectors(int docNumber) 92 throws IOException { 93 return in.getTermFreqVectors(docNumber); 94 } 95 96 public TermFreqVector getTermFreqVector(int docNumber, String field) 97 throws IOException { 98 return in.getTermFreqVector(docNumber, field); 99 } 100 101 public int numDocs() { return in.numDocs(); } 102 public int maxDoc() { return in.maxDoc(); } 103 104 public Document document(int n) throws IOException { return in.document(n); } 105 106 public boolean isDeleted(int n) { return in.isDeleted(n); } 107 public boolean hasDeletions() { return in.hasDeletions(); } 108 protected void doUndeleteAll() throws IOException { in.undeleteAll(); } 109 110 public boolean hasNorms(String field) throws IOException { 111 return in.hasNorms(field); 112 } 113 114 public byte[] norms(String f) throws IOException { return in.norms(f); } 115 public void norms(String f, byte[] bytes, int offset) throws IOException { 116 in.norms(f, bytes, offset); 117 } 118 protected void doSetNorm(int d, String f, byte b) throws IOException { 119 in.setNorm(d, f, b); 120 } 121 122 public TermEnum terms() throws IOException { return in.terms(); } 123 public TermEnum terms(Term t) throws IOException { return in.terms(t); } 124 125 public int docFreq(Term t) throws IOException { return in.docFreq(t); } 126 127 public TermDocs termDocs() throws IOException { return in.termDocs(); } 128 129 public TermPositions termPositions() throws IOException { 130 return in.termPositions(); 131 } 132 133 protected void doDelete(int n) throws IOException { in.delete(n); } 134 protected void doCommit() throws IOException { in.commit(); } 135 protected void doClose() throws IOException { in.close(); } 136 137 public Collection getFieldNames() throws IOException { 138 return in.getFieldNames(); 139 } 140 141 public Collection getFieldNames(boolean indexed) throws IOException { 142 return in.getFieldNames(indexed); 143 } 144 145 public Collection getIndexedFieldNames (Field.TermVector tvSpec){ 146 return in.getIndexedFieldNames(tvSpec); 147 } 148 149 public Collection getFieldNames(IndexReader.FieldOption fieldNames) { 150 return in.getFieldNames(fieldNames); 151 } 152 } 153 | Popular Tags |