01 package gate.creole.annic.apache.lucene.search;
02
03 /**
04 * Copyright 2004 The Apache Software Foundation
05 *
06 * Licensed under the Apache License, Version 2.0 (the "License");
07 * you may not use this file except in compliance with the License.
08 * You may obtain a copy of the License at
09 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 /** A clause in a BooleanQuery. */
20 public class BooleanClause implements java.io.Serializable {
21 /** The query whose matching documents are combined by the boolean query. */
22 public Query query;
23 /** If true, documents documents which <i>do not</i>
24 match this sub-query will <i>not</i> match the boolean query. */
25 public boolean required = false;
26 /** If true, documents documents which <i>do</i>
27 match this sub-query will <i>not</i> match the boolean query. */
28 public boolean prohibited = false;
29
30 /** Constructs a BooleanClause with query <code>q</code>, required
31 <code>r</code> and prohibited <code>p</code>. */
32 public BooleanClause(Query q, boolean r, boolean p) {
33 query = q;
34 required = r;
35 prohibited = p;
36 }
37
38 /** Returns true iff <code>o</code> is equal to this. */
39 public boolean equals(Object o) {
40 if (!(o instanceof BooleanClause))
41 return false;
42 BooleanClause other = (BooleanClause)o;
43 return this.query.equals(other.query)
44 && (this.required == other.required)
45 && (this.prohibited == other.prohibited);
46 }
47
48 /** Returns a hash code value for this object.*/
49 public int hashCode() {
50 return query.hashCode() ^ (this.required?1:0) ^ (this.prohibited?2:0);
51 }
52
53 }
|