From ea9fcfe3fcbf09a4320460e2d10bb36ff2bd9133 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Tue, 16 Jun 2009 14:08:28 +0000 Subject: [PATCH] LUCENE-1694: fix Query.mergeBooleanQueries to take BooleanQuery[] param git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@785222 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/lucene/search/BooleanClause.java | 4 ++-- src/java/org/apache/lucene/search/Query.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/java/org/apache/lucene/search/BooleanClause.java b/src/java/org/apache/lucene/search/BooleanClause.java index 70841a97d63..bf091a56d1d 100644 --- a/src/java/org/apache/lucene/search/BooleanClause.java +++ b/src/java/org/apache/lucene/search/BooleanClause.java @@ -94,9 +94,9 @@ public class BooleanClause implements java.io.Serializable { - /** Returns true iff o is equal to this. */ + /** Returns true if o is equal to this. */ public boolean equals(Object o) { - if (!(o instanceof BooleanClause)) + if (o == null || !(o instanceof BooleanClause)) return false; BooleanClause other = (BooleanClause)o; return this.query.equals(other.query) diff --git a/src/java/org/apache/lucene/search/Query.java b/src/java/org/apache/lucene/search/Query.java index 97a24b9077a..a1dd8a1ab27 100644 --- a/src/java/org/apache/lucene/search/Query.java +++ b/src/java/org/apache/lucene/search/Query.java @@ -169,17 +169,17 @@ public abstract class Query implements java.io.Serializable, Cloneable { * *

A utility for use by {@link #combine(Query[])} implementations. */ - public static Query mergeBooleanQueries(Query[] queries) { + public static Query mergeBooleanQueries(BooleanQuery[] queries) { HashSet allClauses = new HashSet(); for (int i = 0; i < queries.length; i++) { - BooleanClause[] clauses = ((BooleanQuery)queries[i]).getClauses(); + BooleanClause[] clauses = queries[i].getClauses(); for (int j = 0; j < clauses.length; j++) { allClauses.add(clauses[j]); } } boolean coordDisabled = - queries.length==0? false : ((BooleanQuery)queries[0]).isCoordDisabled(); + queries.length==0? false : queries[0].isCoordDisabled(); BooleanQuery result = new BooleanQuery(coordDisabled); Iterator i = allClauses.iterator(); while (i.hasNext()) {