From 324f601c64053d331c61b875c884d13ff7a1b72b Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Fri, 16 Oct 2009 16:30:19 +0000 Subject: [PATCH] LUCENE-1985: More Java5 fixes git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@825989 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 +- .../lucene/search/DisjunctionMaxQuery.java | 23 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index ea2b9b07020..bc0544750e8 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -14,7 +14,7 @@ Changes in runtime behavior API Changes -* LUCENE-1257, LUCENE-1984,...: Port to Java 1.5 [not yet finished]. +* LUCENE-1257, LUCENE-1984, LUCENE-1985, ...: Port to Java 1.5 [not yet finished]. (Uwe Schindler, Robert Muir, Karl Wettin, Paul Elschot, Kay Kay) * LUCENE-1944: Remove (all) deprecated methods/constructors taking diff --git a/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java b/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java index 7ad3350ecbe..fb749bfb569 100644 --- a/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java +++ b/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java @@ -103,8 +103,8 @@ public class DisjunctionMaxQuery extends Query implements Iterable { /* Construct the Weight for this Query searched by searcher. Recursively construct subquery weights. */ public DisjunctionMaxWeight(Searcher searcher) throws IOException { this.similarity = searcher.getSimilarity(); - for (Iterator iter = disjuncts.iterator(); iter.hasNext();) { - weights.add(((Query) iter.next()).createWeight(searcher)); + for (Query disjunctQuery : disjuncts) { + weights.add(disjunctQuery.createWeight(searcher)); } } @@ -120,8 +120,8 @@ public class DisjunctionMaxQuery extends Query implements Iterable { @Override public float sumOfSquaredWeights() throws IOException { float max = 0.0f, sum = 0.0f; - for (Iterator iter = weights.iterator(); iter.hasNext();) { - float sub = ((Weight) iter.next()).sumOfSquaredWeights(); + for (Weight currentWeight : weights) { + float sub = currentWeight.sumOfSquaredWeights(); sum += sub; max = Math.max(max, sub); @@ -134,8 +134,8 @@ public class DisjunctionMaxQuery extends Query implements Iterable { @Override public void normalize(float norm) { norm *= getBoost(); // Incorporate our boost - for (Iterator iter = weights.iterator(); iter.hasNext();) { - ((Weight) iter.next()).normalize(norm); + for (Weight wt : weights) { + wt.normalize(norm); } } @@ -145,8 +145,7 @@ public class DisjunctionMaxQuery extends Query implements Iterable { boolean topScorer) throws IOException { Scorer[] scorers = new Scorer[weights.size()]; int idx = 0; - for (Iterator iter = weights.iterator(); iter.hasNext();) { - Weight w = (Weight) iter.next(); + for (Weight w : weights) { Scorer subScorer = w.scorer(reader, true, false); if (subScorer != null && subScorer.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) { scorers[idx++] = subScorer; @@ -164,8 +163,8 @@ public class DisjunctionMaxQuery extends Query implements Iterable { ComplexExplanation result = new ComplexExplanation(); float max = 0.0f, sum = 0.0f; result.setDescription(tieBreakerMultiplier == 0.0f ? "max of:" : "max plus " + tieBreakerMultiplier + " times others of:"); - for (Iterator iter = weights.iterator(); iter.hasNext();) { - Explanation e = ((Weight) iter.next()).explain(reader, doc); + for (Weight wt : weights) { + Explanation e = wt.explain(reader, doc); if (e.isMatch()) { result.setMatch(Boolean.TRUE); result.addDetail(e); @@ -225,8 +224,8 @@ public class DisjunctionMaxQuery extends Query implements Iterable { // inherit javadoc @Override public void extractTerms(Set terms) { - for (Iterator iter = disjuncts.iterator(); iter.hasNext();) { - ((Query) iter.next()).extractTerms(terms); + for (Query query : disjuncts) { + query.extractTerms(terms); } }