BooleanClausepublic class BooleanClause extends Object implements SerializableA clause in a BooleanQuery. |
Fields Summary |
---|
public Query | queryThe query whose matching documents are combined by the boolean query. | public boolean | requiredIf true, documents documents which do not
match this sub-query will not match the boolean query. | public boolean | prohibitedIf true, documents documents which do
match this sub-query will not match the boolean query. | private Occur | occur |
Constructors Summary |
---|
public BooleanClause(Query q, boolean r, boolean p)Constructs a BooleanClause with query q , required
r and prohibited p .
// TODO: remove for Lucene 2.0
query = q;
required = r;
prohibited = p;
if (required) {
if (prohibited) {
// prohibited && required doesn't make sense, but we want the old behaviour:
occur = Occur.MUST_NOT;
} else {
occur = Occur.MUST;
}
} else {
if (prohibited) {
occur = Occur.MUST_NOT;
} else {
occur = Occur.SHOULD;
}
}
| public BooleanClause(Query query, Occur occur)Constructs a BooleanClause.
this.query = query;
this.occur = occur;
setFields(occur);
|
Methods Summary |
---|
public boolean | equals(java.lang.Object o)Returns true iff o is equal to this.
if (!(o instanceof BooleanClause))
return false;
BooleanClause other = (BooleanClause)o;
return this.query.equals(other.query)
&& (this.required == other.required)
&& (this.prohibited == other.prohibited);
| public org.apache.lucene.search.BooleanClause$Occur | getOccur()
return occur;
| public org.apache.lucene.search.Query | getQuery()
return query;
| public int | hashCode()Returns a hash code value for this object.
return query.hashCode() ^ (this.required?1:0) ^ (this.prohibited?2:0);
| public boolean | isProhibited()
return prohibited;
| public boolean | isRequired()
return required;
| private void | setFields(org.apache.lucene.search.BooleanClause$Occur occur)
if (occur == Occur.MUST) {
required = true;
prohibited = false;
} else if (occur == Occur.SHOULD) {
required = false;
prohibited = false;
} else if (occur == Occur.MUST_NOT) {
required = false;
prohibited = true;
} else {
throw new IllegalArgumentException("Unknown operator " + occur);
}
| public void | setOccur(org.apache.lucene.search.BooleanClause$Occur occur)
this.occur = occur;
setFields(occur);
| public void | setQuery(org.apache.lucene.search.Query query)
this.query = query;
| public java.lang.String | toString()
return occur.toString() + query.toString();
|
|