Lucene.Net  3.0.3
Lucene.Net is a .NET port of the Java Lucene Indexing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties
QueryWrapperFilter.cs
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 using System;
19 
20 using IndexReader = Lucene.Net.Index.IndexReader;
21 
22 namespace Lucene.Net.Search
23 {
24 
37  [Serializable]
39  {
40  private class AnonymousClassDocIdSet:DocIdSet
41  {
42  public AnonymousClassDocIdSet(Lucene.Net.Search.Weight weight, Lucene.Net.Index.IndexReader reader, QueryWrapperFilter enclosingInstance)
43  {
44  InitBlock(weight, reader, enclosingInstance);
45  }
46  private void InitBlock(Lucene.Net.Search.Weight weight, Lucene.Net.Index.IndexReader reader, QueryWrapperFilter enclosingInstance)
47  {
48  this.weight = weight;
49  this.reader = reader;
50  this.enclosingInstance = enclosingInstance;
51  }
52  private Lucene.Net.Search.Weight weight;
53  private Lucene.Net.Index.IndexReader reader;
54  private QueryWrapperFilter enclosingInstance;
55  public QueryWrapperFilter Enclosing_Instance
56  {
57  get
58  {
59  return enclosingInstance;
60  }
61 
62  }
63  public override DocIdSetIterator Iterator()
64  {
65  return weight.Scorer(reader, true, false);
66  }
67 
68  public override bool IsCacheable
69  {
70  get { return false; }
71  }
72  }
73  private Query query;
74 
78  public QueryWrapperFilter(Query query)
79  {
80  this.query = query;
81  }
82 
83  public override DocIdSet GetDocIdSet(IndexReader reader)
84  {
85  Weight weight = query.Weight(new IndexSearcher(reader));
86  return new AnonymousClassDocIdSet(weight, reader, this);
87  }
88 
89  public override System.String ToString()
90  {
91  return "QueryWrapperFilter(" + query + ")";
92  }
93 
94  public override bool Equals(System.Object o)
95  {
96  if (!(o is QueryWrapperFilter))
97  return false;
98  return this.query.Equals(((QueryWrapperFilter) o).query);
99  }
100 
101  public override int GetHashCode()
102  {
103  return query.GetHashCode() ^ unchecked((int) 0x923F64B9);
104  }
105  }
106 }