2 * Copyright 2004 The Apache Software Foundation
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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 namespace Lucene
.Net
.Search
19 /// <summary>A clause in a BooleanQuery. </summary>
21 public class BooleanClause
23 /// <summary>The query whose matching documents are combined by the boolean query. </summary>
25 /// <summary>If true, documents documents which <i>do not</i>
26 /// match this sub-query will <i>not</i> match the boolean query.
28 public bool required
= false;
29 /// <summary>If true, documents documents which <i>do</i>
30 /// match this sub-query will <i>not</i> match the boolean query.
32 public bool prohibited
= false;
34 /// <summary>Constructs a BooleanClause with query <code>q</code>, required
35 /// <code>r</code> and prohibited <code>p</code>.
37 public BooleanClause(Query q
, bool r
, bool p
)
44 /// <summary>Returns true iff <code>o</code> is equal to this. </summary>
45 public override bool Equals(System
.Object o
)
47 if (!(o
is BooleanClause
))
49 BooleanClause other
= (BooleanClause
) o
;
50 return this.query
.Equals(other
.query
) && (this.required
== other
.required
) && (this.prohibited
== other
.prohibited
);
53 /// <summary>Returns a hash code value for this object.</summary>
54 public override int GetHashCode()
56 return query
.GetHashCode() ^
(this.required
?1:0) ^
(this.prohibited
?2:0);