lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r826261 - in /lucene/java/branches/flex_1458: contrib/queries/src/java/org/apache/lucene/search/ src/java/org/apache/lucene/analysis/ src/java/org/apache/lucene/index/ src/java/org/apache/lucene/search/ src/java/org/apache/lucene/store/ src...
Date Sat, 17 Oct 2009 14:35:59 GMT
Author: markrmiller
Date: Sat Oct 17 14:35:58 2009
New Revision: 826261

URL: http://svn.apache.org/viewvc?rev=826261&view=rev
Log:
merge up to r826213

Modified:
    lucene/java/branches/flex_1458/contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/NormalizeCharMap.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/WordlistLoader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/BufferedDeletes.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CheckIndex.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocumentsWriter.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentInfo.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentInfos.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanQuery.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanScorer.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanScorer2.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/IndexInput.java
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
  (props changed)
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/document/TestDateTools.java
  (props changed)
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/document/TestNumberTools.java
  (props changed)
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
  (props changed)

Modified: lucene/java/branches/flex_1458/contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java?rev=826261&r1=826260&r2=826261&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java
(original)
+++ lucene/java/branches/flex_1458/contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java
Sat Oct 17 14:35:58 2009
@@ -38,14 +38,14 @@
 
 public class BooleanFilter extends Filter
 {
-  ArrayList shouldFilters = null;
-  ArrayList notFilters = null;
-  ArrayList mustFilters = null;
+  ArrayList<Filter> shouldFilters = null;
+  ArrayList<Filter> notFilters = null;
+  ArrayList<Filter> mustFilters = null;
   
-  private DocIdSetIterator getDISI(ArrayList filters, int index, IndexReader reader)
+  private DocIdSetIterator getDISI(ArrayList<Filter> filters, int index, IndexReader
reader)
   throws IOException
   {
-    return ((Filter)filters.get(index)).getDocIdSet(reader).iterator();
+    return filters.get(index).getDocIdSet(reader).iterator();
   }
 
   /**
@@ -78,7 +78,7 @@
           res = new OpenBitSetDISI(getDISI(notFilters, i, reader), reader.maxDoc());
           res.flip(0, reader.maxDoc()); // NOTE: may set bits on deleted docs
         } else {
-          DocIdSet dis = ((Filter)notFilters.get(i)).getDocIdSet(reader);
+          DocIdSet dis = notFilters.get(i).getDocIdSet(reader);
           if(dis instanceof OpenBitSet) {
             // optimized case for OpenBitSets
             res.andNot((OpenBitSet) dis);
@@ -94,7 +94,7 @@
         if (res == null) {
           res = new OpenBitSetDISI(getDISI(mustFilters, i, reader), reader.maxDoc());
         } else {
-          DocIdSet dis = ((Filter)mustFilters.get(i)).getDocIdSet(reader);
+          DocIdSet dis = mustFilters.get(i).getDocIdSet(reader);
           if(dis instanceof OpenBitSet) {
             // optimized case for OpenBitSets
             res.and((OpenBitSet) dis);
@@ -132,25 +132,25 @@
   {
     if (filterClause.getOccur().equals(Occur.MUST)) {
       if (mustFilters==null) {
-        mustFilters=new ArrayList();
+        mustFilters=new ArrayList<Filter>();
       }
       mustFilters.add(filterClause.getFilter());
     }
     if (filterClause.getOccur().equals(Occur.SHOULD)) {
       if (shouldFilters==null) {
-        shouldFilters=new ArrayList();
+        shouldFilters=new ArrayList<Filter>();
       }
       shouldFilters.add(filterClause.getFilter());
     }
     if (filterClause.getOccur().equals(Occur.MUST_NOT)) {
       if (notFilters==null) {
-        notFilters=new ArrayList();
+        notFilters=new ArrayList<Filter>();
       }
       notFilters.add(filterClause.getFilter());
     }
   }
 
-  private boolean equalFilters(ArrayList filters1, ArrayList filters2)
+  private boolean equalFilters(ArrayList<Filter> filters1, ArrayList<Filter>
filters2)
   {
      return (filters1 == filters2) ||
               ((filters1 != null) && filters1.equals(filters2));
@@ -191,7 +191,7 @@
     return buffer.toString();
   }
   
-  private void appendFilters(ArrayList filters, String occurString, StringBuilder buffer)
+  private void appendFilters(ArrayList<Filter> filters, String occurString, StringBuilder
buffer)
   {
     if (filters != null) {
       for (int i = 0; i < filters.size(); i++) {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/NormalizeCharMap.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/NormalizeCharMap.java?rev=826261&r1=826260&r2=826261&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/NormalizeCharMap.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/NormalizeCharMap.java
Sat Oct 17 14:35:58 2009
@@ -26,8 +26,7 @@
  */
 public class NormalizeCharMap {
 
-  //Map<Character, NormalizeMap> submap;
-  Map submap;
+  Map<Character, NormalizeCharMap> submap;
   String normStr;
   int diff;
 
@@ -44,9 +43,9 @@
     for(int i = 0; i < singleMatch.length(); i++) {
       char c = singleMatch.charAt(i);
       if (currMap.submap == null) {
-        currMap.submap = new HashMap(1);
+        currMap.submap = new HashMap<Character, NormalizeCharMap>(1);
       }
-      NormalizeCharMap map = (NormalizeCharMap) currMap.submap.get(CharacterCache.valueOf(c));
+      NormalizeCharMap map = currMap.submap.get(CharacterCache.valueOf(c));
       if (map == null) {
         map = new NormalizeCharMap();
         currMap.submap.put(new Character(c), map);

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/WordlistLoader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/WordlistLoader.java?rev=826261&r1=826260&r2=826261&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/WordlistLoader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/WordlistLoader.java
Sat Oct 17 14:35:58 2009
@@ -39,8 +39,8 @@
    * @param wordfile File containing the wordlist
    * @return A HashSet with the file's words
    */
-  public static HashSet getWordSet(File wordfile) throws IOException {
-    HashSet result = new HashSet();
+  public static HashSet<String> getWordSet(File wordfile) throws IOException {
+    HashSet<String> result = new HashSet<String>();
     FileReader reader = null;
     try {
       reader = new FileReader(wordfile);
@@ -63,8 +63,8 @@
    * @param comment The comment string to ignore
    * @return A HashSet with the file's words
    */
-  public static HashSet getWordSet(File wordfile, String comment) throws IOException {
-    HashSet result = new HashSet();
+  public static HashSet<String> getWordSet(File wordfile, String comment) throws IOException
{
+    HashSet<String> result = new HashSet<String>();
     FileReader reader = null;
     try {
       reader = new FileReader(wordfile);
@@ -87,8 +87,8 @@
    * @param reader Reader containing the wordlist
    * @return A HashSet with the reader's words
    */
-  public static HashSet getWordSet(Reader reader) throws IOException {
-    HashSet result = new HashSet();
+  public static HashSet<String> getWordSet(Reader reader) throws IOException {
+    HashSet<String> result = new HashSet<String>();
     BufferedReader br = null;
     try {
       if (reader instanceof BufferedReader) {
@@ -118,8 +118,8 @@
    * @param comment The string representing a comment.
    * @return A HashSet with the reader's words
    */
-  public static HashSet getWordSet(Reader reader, String comment) throws IOException {
-    HashSet result = new HashSet();
+  public static HashSet<String> getWordSet(Reader reader, String comment) throws IOException
{
+    HashSet<String> result = new HashSet<String>();
     BufferedReader br = null;
     try {
       if (reader instanceof BufferedReader) {
@@ -151,10 +151,10 @@
    * @return stem dictionary that overrules the stemming algorithm
    * @throws IOException 
    */
-  public static HashMap getStemDict(File wordstemfile) throws IOException {
+  public static HashMap<String, String> getStemDict(File wordstemfile) throws IOException
{
     if (wordstemfile == null)
       throw new NullPointerException("wordstemfile may not be null");
-    HashMap result = new HashMap();
+    HashMap<String, String> result = new HashMap<String, String>();
     BufferedReader br = null;
     FileReader fr = null;
     try {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/BufferedDeletes.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/BufferedDeletes.java?rev=826261&r1=826260&r2=826261&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/BufferedDeletes.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/BufferedDeletes.java Sat
Oct 17 14:35:58 2009
@@ -20,9 +20,10 @@
 import java.util.HashMap;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Iterator;
 import java.util.Map.Entry;
 
+import org.apache.lucene.search.Query;
+
 /** Holds buffered deletes, by docID, term or query.  We
  *  hold two instances of this class: one for the deletes
  *  prior to the last flush, the other for deletes after
@@ -32,9 +33,9 @@
  *  previously flushed segments. */
 class BufferedDeletes {
   int numTerms;
-  HashMap terms = new HashMap();
-  HashMap queries = new HashMap();
-  List docIDs = new ArrayList();
+  HashMap<Term,Num> terms = new HashMap<Term,Num>();
+  HashMap<Query,Integer> queries = new HashMap<Query,Integer>();
+  List<Integer> docIDs = new ArrayList<Integer>();
   long bytesUsed;
 
   // Number of documents a delete term applies to.
@@ -103,42 +104,38 @@
                           MergePolicy.OneMerge merge,
                           int mergeDocCount) {
 
-    final HashMap newDeleteTerms;
+    final HashMap<Term,Num> newDeleteTerms;
 
     // Remap delete-by-term
     if (terms.size() > 0) {
-      newDeleteTerms = new HashMap();
-      Iterator iter = terms.entrySet().iterator();
-      while(iter.hasNext()) {
-        Entry entry = (Entry) iter.next();
-        Num num = (Num) entry.getValue();
+      newDeleteTerms = new HashMap<Term, Num>();
+      for(Entry<Term,Num> entry : terms.entrySet()) {
+        Num num = entry.getValue();
         newDeleteTerms.put(entry.getKey(),
                            new Num(mapper.remap(num.getNum())));
       }
-    } else
+    } else 
       newDeleteTerms = null;
+    
 
     // Remap delete-by-docID
-    final List newDeleteDocIDs;
+    final List<Integer> newDeleteDocIDs;
 
     if (docIDs.size() > 0) {
-      newDeleteDocIDs = new ArrayList(docIDs.size());
-      Iterator iter = docIDs.iterator();
-      while(iter.hasNext()) {
-        Integer num = (Integer) iter.next();
+      newDeleteDocIDs = new ArrayList<Integer>(docIDs.size());
+      for (Integer num : docIDs) {
         newDeleteDocIDs.add(Integer.valueOf(mapper.remap(num.intValue())));
       }
-    } else
+    } else 
       newDeleteDocIDs = null;
+    
 
     // Remap delete-by-query
-    final HashMap newDeleteQueries;
+    final HashMap<Query,Integer> newDeleteQueries;
     
     if (queries.size() > 0) {
-      newDeleteQueries = new HashMap(queries.size());
-      Iterator iter = queries.entrySet().iterator();
-      while(iter.hasNext()) {
-        Entry entry = (Entry) iter.next();
+      newDeleteQueries = new HashMap<Query, Integer>(queries.size());
+      for(Entry<Query,Integer> entry: queries.entrySet()) {
         Integer num = (Integer) entry.getValue();
         newDeleteQueries.put(entry.getKey(),
                              Integer.valueOf(mapper.remap(num.intValue())));

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CheckIndex.java?rev=826261&r1=826260&r2=826261&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CheckIndex.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CheckIndex.java Sat Oct
17 14:35:58 2009
@@ -85,13 +85,13 @@
 
     /** Empty unless you passed specific segments list to check as optional 3rd argument.
      *  @see CheckIndex#checkIndex(List) */
-    public List/*<String>*/ segmentsChecked = new ArrayList();
+    public List<String> segmentsChecked = new ArrayList<String>();
   
     /** True if the index was created with a newer version of Lucene than the CheckIndex
tool. */
     public boolean toolOutOfDate;
 
     /** List of {@link SegmentInfoStatus} instances, detailing status of each segment. */
-    public List/*<SegmentInfoStatus*/ segmentInfos = new ArrayList();
+    public List<SegmentInfoStatus> segmentInfos = new ArrayList<SegmentInfoStatus>();
   
     /** Directory index is in. */
     public Directory dir;
@@ -534,7 +534,7 @@
       }
 
       // Keeper
-      result.newSegments.add(info.clone());
+      result.newSegments.add((SegmentInfo) info.clone());
     }
 
     if (0 == result.numBadSegments) {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocumentsWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocumentsWriter.java?rev=826261&r1=826260&r2=826261&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocumentsWriter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocumentsWriter.java Sat
Oct 17 14:35:58 2009
@@ -975,12 +975,9 @@
     boolean any = false;
 
     // Delete by term
-    Iterator iter = deletesFlushed.terms.entrySet().iterator();
-    
     try {
-      while (iter.hasNext()) {
-        Entry entry = (Entry) iter.next();
-        Term term = (Term) entry.getKey();
+      for (Entry<Term, BufferedDeletes.Num> entry: deletesFlushed.terms.entrySet())
{
+        Term term = entry.getKey();
 
         DocsEnum docs = reader.termDocsEnum(reader.getDeletedDocs(), term.field, new TermRef(term.text));
         if (docs != null) {
@@ -1000,9 +997,8 @@
     }
 
     // Delete by docID
-    iter = deletesFlushed.docIDs.iterator();
-    while(iter.hasNext()) {
-      int docID = ((Integer) iter.next()).intValue();
+    for (Integer docIdInt : deletesFlushed.docIDs) {
+      int docID = docIdInt.intValue();
       if (docID >= docIDStart && docID < docEnd) {
         reader.deleteDocument(docID-docIDStart);
         any = true;
@@ -1011,11 +1007,9 @@
 
     // Delete by query
     IndexSearcher searcher = new IndexSearcher(reader);
-    iter = deletesFlushed.queries.entrySet().iterator();
-    while(iter.hasNext()) {
-      Entry entry = (Entry) iter.next();
-      Query query = (Query) entry.getKey();
-      int limit = ((Integer) entry.getValue()).intValue();
+    for (Entry<Query, Integer> entry : deletesFlushed.queries.entrySet()) {
+      Query query = entry.getKey();
+      int limit = entry.getValue().intValue();
       Weight weight = query.weight(searcher);
       Scorer scorer = weight.scorer(reader, true, false);
       if (scorer != null) {
@@ -1037,7 +1031,7 @@
   // delete term will be applied to those documents as well
   // as the disk segments.
   synchronized private void addDeleteTerm(Term term, int docCount) {
-    BufferedDeletes.Num num = (BufferedDeletes.Num) deletesInRAM.terms.get(term);
+    BufferedDeletes.Num num = deletesInRAM.terms.get(term);
     final int docIDUpto = flushedDocCount + docCount;
     if (num == null)
       deletesInRAM.terms.put(term, new BufferedDeletes.Num(docIDUpto));

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentInfo.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentInfo.java?rev=826261&r1=826260&r2=826261&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentInfo.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentInfo.java Sat Oct
17 14:35:58 2009
@@ -75,7 +75,7 @@
                                                   // and true for newly created merged segments
(both
                                                   // compound and non compound).
   
-  private List files;                             // cached list of files that this segment
uses
+  private List<String> files;                             // cached list of files that
this segment uses
                                                   // in the Directory
 
   long sizeInBytes = -1;                          // total byte size of all of our files
(computed on demand)
@@ -625,14 +625,14 @@
    * modify it.
    */
 
-  public List files() throws IOException {
+  public List<String> files() throws IOException {
 
     if (files != null) {
       // Already cached:
       return files;
     }
     
-    files = new ArrayList();
+    files = new ArrayList<String>();
     
     boolean useCompoundFile = getUseCompoundFile();
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentInfos.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentInfos.java?rev=826261&r1=826260&r2=826261&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentInfos.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentInfos.java Sat
Oct 17 14:35:58 2009
@@ -42,7 +42,7 @@
  * <p><b>NOTE:</b> This API is new and still experimental
  * (subject to change suddenly in the next release)</p>
  */
-public final class SegmentInfos extends Vector {
+public final class SegmentInfos extends Vector<SegmentInfo> {
 
   /** The file format version, a negative number. */
   /* Works since counter, the old 1st entry, is always >= 0 */
@@ -108,7 +108,7 @@
                                    // or wrote; this is normally the same as generation except
if
                                    // there was an IOException that had interrupted a commit
 
-  private Map userData = Collections.EMPTY_MAP;       // Opaque Map<String, String>
that user can specify during IndexWriter.commit
+  private Map<String,String> userData = Collections.<String,String>emptyMap();
      // Opaque Map<String, String> that user can specify during IndexWriter.commit
 
   /**
    * If non-null, information about loading segments_N files
@@ -275,10 +275,10 @@
         } else if (0 != input.readByte()) {
           userData = Collections.singletonMap("userData", input.readString());
         } else {
-          userData = Collections.EMPTY_MAP;
+          userData = Collections.<String,String>emptyMap();
         }
       } else {
-        userData = Collections.EMPTY_MAP;
+        userData = Collections.<String,String>emptyMap();
       }
 
       if (format <= FORMAT_CHECKSUM) {
@@ -383,9 +383,9 @@
     for(int i=0;i<sis.size();i++) {
       // nocommit
       assert sis.info(i).getCodec() != null;
-      sis.set(i, sis.info(i).clone());
+      sis.set(i, (SegmentInfo) sis.info(i).clone());
     }
-    sis.userData = new HashMap(userData);
+    sis.userData = new HashMap<String,String>(userData);
     return sis;
   }
 
@@ -446,7 +446,7 @@
    * @throws CorruptIndexException if the index is corrupt
    * @throws IOException if there is a low-level IO error
    */
-  public static Map readCurrentUserData(Directory directory, Codecs codecs)
+  public static Map<String,String> readCurrentUserData(Directory directory, Codecs
codecs)
     throws CorruptIndexException, IOException {
     SegmentInfos sis = new SegmentInfos();
     sis.read(directory, codecs);
@@ -825,8 +825,8 @@
    *  associated with any "external" segments are skipped).
    *  The returned collection is recomputed on each
    *  invocation.  */
-  public Collection files(Directory dir, boolean includeSegmentsFile) throws IOException
{
-    HashSet files = new HashSet();
+  public Collection<String> files(Directory dir, boolean includeSegmentsFile) throws
IOException {
+    HashSet<String> files = new HashSet<String>();
     if (includeSegmentsFile) {
       files.add(getCurrentSegmentFileName());
     }
@@ -920,13 +920,13 @@
     return buffer.toString();
   }
 
-  public Map getUserData() {
+  public Map<String,String> getUserData() {
     return userData;
   }
 
-  void setUserData(Map data) {
+  void setUserData(Map<String,String> data) {
     if (data == null) {
-      userData = Collections.EMPTY_MAP;
+      userData = Collections.<String,String>emptyMap();
     } else {
       userData = data;
     }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanQuery.java?rev=826261&r1=826260&r2=826261&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanQuery.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanQuery.java Sat
Oct 17 14:35:58 2009
@@ -29,7 +29,7 @@
   * queries, e.g. {@link TermQuery}s, {@link PhraseQuery}s or other
   * BooleanQuerys.
   */
-public class BooleanQuery extends Query {
+public class BooleanQuery extends Query implements Iterable<BooleanClause> {
 
   private static int maxClauseCount = 1024;
 
@@ -62,7 +62,7 @@
     BooleanQuery.maxClauseCount = maxClauseCount;
   }
 
-  private ArrayList clauses = new ArrayList();
+  private ArrayList<BooleanClause> clauses = new ArrayList<BooleanClause>();
   private boolean disableCoord;
 
   /** Constructs an empty boolean query. */
@@ -158,11 +158,17 @@
 
   /** Returns the set of clauses in this query. */
   public BooleanClause[] getClauses() {
-    return (BooleanClause[])clauses.toArray(new BooleanClause[clauses.size()]);
+    return clauses.toArray(new BooleanClause[clauses.size()]);
   }
 
   /** Returns the list of clauses in this query. */
-  public List clauses() { return clauses; }
+  public List<BooleanClause> clauses() { return clauses; }
+
+  /** Returns an iterator on the clauses in this query. It implements the {@link Iterable}
interface to
+   * make it possible to do:
+   * <pre>for (BooleanClause clause : booleanQuery) {}</pre>
+   */
+  public final Iterator<BooleanClause> iterator() { return clauses().iterator(); }
 
   /**
    * Expert: the Weight for BooleanQuery, used to
@@ -174,21 +180,25 @@
   protected class BooleanWeight extends Weight {
     /** The Similarity implementation. */
     protected Similarity similarity;
-    protected ArrayList weights;
+    protected ArrayList<Weight> weights;
 
     public BooleanWeight(Searcher searcher)
       throws IOException {
       this.similarity = getSimilarity(searcher);
-      weights = new ArrayList(clauses.size());
+      weights = new ArrayList<Weight>(clauses.size());
       for (int i = 0 ; i < clauses.size(); i++) {
         BooleanClause c = (BooleanClause)clauses.get(i);
         weights.add(c.getQuery().createWeight(searcher));
       }
     }
 
+    @Override
     public Query getQuery() { return BooleanQuery.this; }
+
+    @Override
     public float getValue() { return getBoost(); }
 
+    @Override
     public float sumOfSquaredWeights() throws IOException {
       float sum = 0.0f;
       for (int i = 0 ; i < weights.size(); i++) {
@@ -207,15 +217,16 @@
     }
 
 
+    @Override
     public void normalize(float norm) {
       norm *= getBoost();                         // incorporate boost
-      for (Iterator iter = weights.iterator(); iter.hasNext();) {
-        Weight w = (Weight) iter.next();
+      for (Weight w : weights) {
         // normalize all clauses, (even if prohibited in case of side affects)
         w.normalize(norm);
       }
     }
 
+    @Override
     public Explanation explain(IndexReader reader, int doc)
       throws IOException {
       final int minShouldMatch =
@@ -227,9 +238,10 @@
       float sum = 0.0f;
       boolean fail = false;
       int shouldMatchCount = 0;
-      for (Iterator wIter = weights.iterator(), cIter = clauses.iterator(); wIter.hasNext();)
{
-        Weight w = (Weight) wIter.next();
-        BooleanClause c = (BooleanClause) cIter.next();
+      Iterator<BooleanClause> cIter = clauses.iterator();
+      for (Iterator<Weight> wIter = weights.iterator(); wIter.hasNext();) {
+        Weight w = wIter.next();
+        BooleanClause c = cIter.next();
         if (w.scorer(reader, true, true) == null) {
           continue;
         }
@@ -287,14 +299,15 @@
       }
     }
 
+    @Override
     public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer)
         throws IOException {
-      List required = new ArrayList();
-      List prohibited = new ArrayList();
-      List optional = new ArrayList();
-      for (Iterator wIter = weights.iterator(), cIter = clauses.iterator(); wIter.hasNext();)
{
-        Weight w = (Weight) wIter.next();
-        BooleanClause c = (BooleanClause) cIter.next();
+      List<Scorer> required = new ArrayList<Scorer>();
+      List<Scorer> prohibited = new ArrayList<Scorer>();
+      List<Scorer> optional = new ArrayList<Scorer>();
+      Iterator<BooleanClause> cIter = clauses.iterator();
+      for (Weight w  : weights) {
+        BooleanClause c =  cIter.next();
         Scorer subScorer = w.scorer(reader, true, false);
         if (subScorer == null) {
           if (c.isRequired()) {
@@ -328,10 +341,10 @@
       return new BooleanScorer2(similarity, minNrShouldMatch, required, prohibited, optional);
     }
     
+    @Override
     public boolean scoresDocsOutOfOrder() {
       int numProhibited = 0;
-      for (Iterator cIter = clauses.iterator(); cIter.hasNext();) {
-        BooleanClause c = (BooleanClause) cIter.next();
+      for (BooleanClause c : clauses) {
         if (c.isRequired()) {
           return false; // BS2 (in-order) will be used by scorer()
         } else if (c.isProhibited()) {
@@ -349,10 +362,12 @@
     
   }
 
+  @Override
   public Weight createWeight(Searcher searcher) throws IOException {
     return new BooleanWeight(searcher);
   }
 
+  @Override
   public Query rewrite(IndexReader reader) throws IOException {
     if (minNrShouldMatch == 0 && clauses.size() == 1) {                    // optimize
1-clause queries
       BooleanClause c = (BooleanClause)clauses.get(0);
@@ -372,7 +387,7 @@
 
     BooleanQuery clone = null;                    // recursively rewrite
     for (int i = 0 ; i < clauses.size(); i++) {
-      BooleanClause c = (BooleanClause)clauses.get(i);
+      BooleanClause c = clauses.get(i);
       Query query = c.getQuery().rewrite(reader);
       if (query != c.getQuery()) {                     // clause rewrote: must clone
         if (clone == null)
@@ -387,20 +402,22 @@
   }
 
   // inherit javadoc
+  @Override
   public void extractTerms(Set<Term> terms) {
-      for (Iterator i = clauses.iterator(); i.hasNext();) {
-          BooleanClause clause = (BooleanClause) i.next();
+      for (BooleanClause clause : clauses) {
           clause.getQuery().extractTerms(terms);
         }
   }
 
+  @Override
   public Object clone() {
     BooleanQuery clone = (BooleanQuery)super.clone();
-    clone.clauses = (ArrayList)this.clauses.clone();
+    clone.clauses = (ArrayList<BooleanClause>)this.clauses.clone();
     return clone;
   }
 
   /** Prints a user-readable version of this query. */
+  @Override
   public String toString(String field) {
     StringBuilder buffer = new StringBuilder();
     boolean needParens=(getBoost() != 1.0) || (getMinimumNumberShouldMatch()>0) ;
@@ -409,7 +426,7 @@
     }
 
     for (int i = 0 ; i < clauses.size(); i++) {
-      BooleanClause c = (BooleanClause)clauses.get(i);
+      BooleanClause c = clauses.get(i);
       if (c.isProhibited())
         buffer.append("-");
       else if (c.isRequired())
@@ -450,6 +467,7 @@
   }
 
   /** Returns true iff <code>o</code> is equal to this. */
+  @Override
   public boolean equals(Object o) {
     if (!(o instanceof BooleanQuery))
       return false;
@@ -460,6 +478,7 @@
   }
 
   /** Returns a hash code value for this object.*/
+  @Override
   public int hashCode() {
     return Float.floatToIntBits(getBoost()) ^ clauses.hashCode()
            + getMinimumNumberShouldMatch();

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanScorer.java?rev=826261&r1=826260&r2=826261&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanScorer.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanScorer.java Sat
Oct 17 14:35:58 2009
@@ -18,7 +18,6 @@
  */
 
 import java.io.IOException;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.lucene.index.IndexReader;
@@ -182,13 +181,12 @@
   private int doc = -1;
 
   BooleanScorer(Similarity similarity, int minNrShouldMatch,
-      List optionalScorers, List prohibitedScorers) throws IOException {
+      List<Scorer> optionalScorers, List<Scorer> prohibitedScorers) throws IOException
{
     super(similarity);
     this.minNrShouldMatch = minNrShouldMatch;
 
     if (optionalScorers != null && optionalScorers.size() > 0) {
-      for (Iterator si = optionalScorers.iterator(); si.hasNext();) {
-        Scorer scorer = (Scorer) si.next();
+      for (Scorer scorer : optionalScorers) {
         maxCoord++;
         if (scorer.nextDoc() != NO_MORE_DOCS) {
           scorers = new SubScorer(scorer, false, false, bucketTable.newCollector(0), scorers);
@@ -197,8 +195,7 @@
     }
     
     if (prohibitedScorers != null && prohibitedScorers.size() > 0) {
-      for (Iterator si = prohibitedScorers.iterator(); si.hasNext();) {
-        Scorer scorer = (Scorer) si.next();
+      for (Scorer scorer : prohibitedScorers) {
         int mask = nextMask;
         nextMask = nextMask << 1;
         prohibitedMask |= mask;                     // update prohibited mask

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanScorer2.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanScorer2.java?rev=826261&r1=826260&r2=826261&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanScorer2.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanScorer2.java Sat
Oct 17 14:35:58 2009
@@ -31,9 +31,9 @@
  */
 class BooleanScorer2 extends Scorer {
   
-  private final List requiredScorers;
-  private final List optionalScorers;
-  private final List prohibitedScorers;
+  private final List<Scorer> requiredScorers;
+  private final List<Scorer> optionalScorers;
+  private final List<Scorer> prohibitedScorers;
 
   private class Coordinator {
     float[] coordFactors = null;
@@ -81,7 +81,7 @@
    *          the list of optional scorers.
    */
   public BooleanScorer2(Similarity similarity, int minNrShouldMatch,
-      List required, List prohibited, List optional) throws IOException {
+      List<Scorer> required, List<Scorer> prohibited, List<Scorer> optional)
throws IOException {
     super(similarity);
     if (minNrShouldMatch < 0) {
       throw new IllegalArgumentException("Minimum number of optional scorers should not be
negative");
@@ -138,7 +138,7 @@
     }
   }
 
-  private Scorer countingDisjunctionSumScorer(final List scorers,
+  private Scorer countingDisjunctionSumScorer(final List<Scorer> scorers,
       int minNrShouldMatch) throws IOException {
     // each scorer from the list counted as a single matcher
     return new DisjunctionSumScorer(scorers, minNrShouldMatch) {
@@ -162,7 +162,7 @@
 
   private static final Similarity defaultSimilarity = Similarity.getDefault();
 
-  private Scorer countingConjunctionSumScorer(List requiredScorers) throws IOException {
+  private Scorer countingConjunctionSumScorer(List<Scorer> requiredScorers) throws
IOException {
     // each scorer from the list counted as a single matcher
     final int requiredNrMatchers = requiredScorers.size();
     return new ConjunctionScorer(defaultSimilarity, requiredScorers) {
@@ -220,7 +220,7 @@
 
   private Scorer makeCountingSumScorerSomeReq() throws IOException { // At least one required
scorer.
     if (optionalScorers.size() == minNrShouldMatch) { // all optional scorers also required.
-      ArrayList allReq = new ArrayList(requiredScorers);
+      ArrayList<Scorer> allReq = new ArrayList<Scorer>(requiredScorers);
       allReq.addAll(optionalScorers);
       return addProhibitedScorers(countingConjunctionSumScorer(allReq));
     } else { // optionalScorers.size() > minNrShouldMatch, and at least one required scorer

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java?rev=826261&r1=826260&r2=826261&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
Sat Oct 17 14:35:58 2009
@@ -209,7 +209,7 @@
    * @return a copy of us (but reuse, don't copy, our subqueries) */
   public Object clone() {
     DisjunctionMaxQuery clone = (DisjunctionMaxQuery)super.clone();
-    clone.disjuncts = (ArrayList)this.disjuncts.clone();
+    clone.disjuncts = (ArrayList<Query>)this.disjuncts.clone();
     return clone;
   }
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/IndexInput.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/IndexInput.java?rev=826261&r1=826260&r2=826261&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/IndexInput.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/IndexInput.java Sat Oct
17 14:35:58 2009
@@ -228,9 +228,8 @@
     return clone;
   }
 
-  // returns Map<String, String>
-  public Map readStringStringMap() throws IOException {
-    final Map map = new HashMap();
+  public Map<String,String> readStringStringMap() throws IOException {
+    final Map<String,String> map = new HashMap<String,String>();
     final int count = readInt();
     for(int i=0;i<count;i++) {
       final String key = readString();

Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Oct 17 14:35:58 2009
@@ -1,2 +1,2 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:748824
-/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:824912-825292
+/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:824912-825292,826213

Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/document/TestDateTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Oct 17 14:35:58 2009
@@ -1,2 +1,2 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestDateTools.java:748824
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:824912-825292
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:824912-825292,826213

Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/document/TestNumberTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Oct 17 14:35:58 2009
@@ -1,2 +1,2 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestNumberTools.java:748824
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:824912-825292
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:824912-825292,826213

Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Oct 17 14:35:58 2009
@@ -1,2 +1,2 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:748824
-/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:824912-825292
+/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:824912-825292,826213



Mime
View raw message