cvsimport
[beagle.git] / beagled / Lucene.Net / Index / FilterIndexReader.cs
blob98a674869db0b4abf064e3a42317214c2f17b70f
1 /*
2 * Copyright 2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using System;
18 using Document = Lucene.Net.Documents.Document;
19 using Field = Lucene.Net.Documents.Field;
21 namespace Lucene.Net.Index
24 /// <summary>A <code>FilterIndexReader</code> contains another IndexReader, which it
25 /// uses as its basic source of data, possibly transforming the data along the
26 /// way or providing additional functionality. The class
27 /// <code>FilterIndexReader</code> itself simply implements all abstract methods
28 /// of <code>IndexReader</code> with versions that pass all requests to the
29 /// contained index reader. Subclasses of <code>FilterIndexReader</code> may
30 /// further override some of these methods and may also provide additional
31 /// methods and fields.
32 /// </summary>
33 public class FilterIndexReader : IndexReader
36 /// <summary>Base class for filtering {@link TermDocs} implementations. </summary>
37 public class FilterTermDocs : TermDocs
39 protected internal TermDocs in_Renamed;
41 public FilterTermDocs(TermDocs in_Renamed)
43 this.in_Renamed = in_Renamed;
46 public virtual void Seek(Term term)
48 in_Renamed.Seek(term);
50 public virtual void Seek(TermEnum termEnum)
52 in_Renamed.Seek(termEnum);
54 public virtual int Doc()
56 return in_Renamed.Doc();
58 public virtual int Freq()
60 return in_Renamed.Freq();
62 public virtual bool Next()
64 return in_Renamed.Next();
66 public virtual int Read(int[] docs, int[] freqs)
68 return in_Renamed.Read(docs, freqs);
70 public virtual bool SkipTo(int i)
72 return in_Renamed.SkipTo(i);
74 public virtual void Close()
76 in_Renamed.Close();
80 /// <summary>Base class for filtering {@link TermPositions} implementations. </summary>
81 public class FilterTermPositions : FilterTermDocs, TermPositions
84 public FilterTermPositions(TermPositions in_Renamed) : base(in_Renamed)
88 public virtual int NextPosition()
90 return ((TermPositions) this.in_Renamed).NextPosition();
94 /// <summary>Base class for filtering {@link TermEnum} implementations. </summary>
95 public class FilterTermEnum : TermEnum
97 protected internal TermEnum in_Renamed;
99 public FilterTermEnum(TermEnum in_Renamed)
101 this.in_Renamed = in_Renamed;
104 public override bool Next()
106 return in_Renamed.Next();
108 public override Term Term()
110 return in_Renamed.Term();
112 public override int DocFreq()
114 return in_Renamed.DocFreq();
116 public override void Close()
118 in_Renamed.Close();
122 protected internal IndexReader in_Renamed;
124 /// <summary> <p>Construct a FilterIndexReader based on the specified base reader.
125 /// Directory locking for delete, undeleteAll, and setNorm operations is
126 /// left to the base reader.</p>
127 /// <p>Note that base reader is closed if this FilterIndexReader is closed.</p>
128 /// </summary>
129 /// <param name="in">specified base reader.
130 /// </param>
131 public FilterIndexReader(IndexReader in_Renamed):base(in_Renamed.Directory())
133 this.in_Renamed = in_Renamed;
136 public override TermFreqVector[] GetTermFreqVectors(int docNumber)
138 return in_Renamed.GetTermFreqVectors(docNumber);
141 public override TermFreqVector GetTermFreqVector(int docNumber, System.String field)
143 return in_Renamed.GetTermFreqVector(docNumber, field);
146 public override int NumDocs()
148 return in_Renamed.NumDocs();
150 public override int MaxDoc()
152 return in_Renamed.MaxDoc();
155 public override Document Document(int n)
157 return in_Renamed.Document(n);
160 public override bool IsDeleted(int n)
162 return in_Renamed.IsDeleted(n);
164 public override bool HasDeletions()
166 return in_Renamed.HasDeletions();
168 protected internal override void DoUndeleteAll()
170 in_Renamed.UndeleteAll();
173 public override bool HasNorms(System.String field)
175 return in_Renamed.HasNorms(field);
178 public override byte[] Norms(System.String f)
180 return in_Renamed.Norms(f);
182 public override void Norms(System.String f, byte[] bytes, int offset)
184 in_Renamed.Norms(f, bytes, offset);
186 protected internal override void DoSetNorm(int d, System.String f, byte b)
188 in_Renamed.SetNorm(d, f, b);
191 public override TermEnum Terms()
193 return in_Renamed.Terms();
195 public override TermEnum Terms(Term t)
197 return in_Renamed.Terms(t);
200 public override int DocFreq(Term t)
202 return in_Renamed.DocFreq(t);
205 public override TermDocs TermDocs()
207 return in_Renamed.TermDocs();
210 public override TermPositions TermPositions()
212 return in_Renamed.TermPositions();
215 protected internal override void DoDelete(int n)
217 in_Renamed.Delete(n);
219 protected internal override void DoCommit()
221 in_Renamed.Commit();
223 protected internal override void DoClose()
225 in_Renamed.Close();
228 public override System.Collections.ICollection GetFieldNames()
230 return in_Renamed.GetFieldNames();
233 public override System.Collections.ICollection GetFieldNames(bool indexed)
235 return in_Renamed.GetFieldNames(indexed);
238 public override System.Collections.ICollection GetIndexedFieldNames(Field.TermVector tvSpec)
240 return in_Renamed.GetIndexedFieldNames(tvSpec);
243 public override System.Collections.ICollection GetFieldNames(IndexReader.FieldOption fieldNames)
245 return in_Renamed.GetFieldNames(fieldNames);