jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r526677 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene: AbstractWeight.java MatchAllWeight.java RangeQuery.java WildcardQuery.java
Date Mon, 09 Apr 2007 09:01:55 GMT
Author: jukka
Date: Mon Apr  9 02:01:54 2007
New Revision: 526677

URL: http://svn.apache.org/viewvc?view=rev&rev=526677
Log:
JCR-835: Replaced the factory interface with an abstract factory method to avoid the troublesome
anonymous inner instances.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractWeight.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllWeight.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractWeight.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractWeight.java?view=diff&rev=526677&r1=526676&r2=526677
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractWeight.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractWeight.java
Mon Apr  9 02:01:54 2007
@@ -35,11 +35,6 @@
     protected final Searcher searcher;
 
     /**
-     * The factory, which creates the scorer instances for this weight.
-     */
-    private final ScorerFactory factory;
-
-    /**
      * Creates a new <code>AbstractWeight</code> for the given
      * <code>searcher</code>. Specific scorer instances are created using the
      * provided scorer <code>factory</code>.
@@ -47,12 +42,22 @@
      * @param searcher the searcher instance for this weight.
      * @param factory the scorer factory.
      */
-    public AbstractWeight(Searcher searcher, ScorerFactory factory) {
+    public AbstractWeight(Searcher searcher) {
         this.searcher = searcher;
-        this.factory = factory;
     }
 
     /**
+     * Abstract factory method for crating a scorer instance for the
+     * specified reader.
+     *
+     * @param reader the index reader the created scorer instance should use
+     * @return the scorer instance
+     * @throws IOException if an error occurs while reading from the index
+     */
+    protected abstract Scorer createScorer(IndexReader reader)
+            throws IOException;
+
+    /**
      * {@inheritDoc}
      * <p/>
      * Returns a {@link MultiScorer} if the passed <code>reader</code> is of
@@ -76,23 +81,8 @@
 
             return new MultiScorer(searcher.getSimilarity(), scorers, starts);
         } else {
-            return factory.createScorer(reader);
+            return createScorer(reader);
         }
     }
 
-    /**
-     * Simple factory for creating scorer instances.
-     */
-    public interface ScorerFactory {
-
-        /**
-         * Creates a Scorer instance for the specified reader.
-         *
-         * @param reader the index reader the created scorer instance should
-         *               use.
-         * @return the scorer instance.
-         * @throws IOException if an error occurs while reading from the index.
-         */
-        public Scorer createScorer(IndexReader reader) throws IOException;
-    }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllWeight.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllWeight.java?view=diff&rev=526677&r1=526676&r2=526677
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllWeight.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllWeight.java
Mon Apr  9 02:01:54 2007
@@ -31,6 +31,11 @@
 class MatchAllWeight extends AbstractWeight {
 
     /**
+     * Name of the field to match.
+     */
+    private final String field;
+
+    /**
      * the MatchAllQuery
      */
     private final Query query;
@@ -53,14 +58,22 @@
     /**
      * @param query
      * @param searcher
+     * @param field name of the field to match 
      */
-    MatchAllWeight(Query query, Searcher searcher, final String field) {
-        super(searcher, new ScorerFactory() {
-            public Scorer createScorer(IndexReader reader) throws IOException {
-                return new MatchAllScorer(reader, field);
-            }
-        });
+    MatchAllWeight(Query query, Searcher searcher, String field) {
+        super(searcher);
         this.query = query;
+        this.field = field;
+    }
+
+    /**
+     * Creates a {@link MatchAllScorer} instance.
+     *
+     * @param reader index reader
+     * @return a {@link MatchAllScorer} instance
+     */
+    protected Scorer createScorer(IndexReader reader) throws IOException {
+        return new MatchAllScorer(reader, field);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java?view=diff&rev=526677&r1=526676&r2=526677
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
Mon Apr  9 02:01:54 2007
@@ -183,13 +183,19 @@
          *
          * @param searcher a <code>Searcher</code> instance.
          */
-        RangeQueryWeight(final Searcher searcher) {
-            super(searcher, new ScorerFactory() {
-                public Scorer createScorer(IndexReader reader) {
-                    return new RangeQueryScorer(searcher.getSimilarity(), reader);
-                }
-            });
+        RangeQueryWeight(Searcher searcher) {
+            super(searcher);
         }
+
+        /**
+         * Creates a {@link RangeQueryScorer} instance.
+         *
+         * @param reader index reader
+         * @return a {@link RangeQueryScorer} instance
+         */
+        protected Scorer createScorer(IndexReader reader) {
+            return new RangeQueryScorer(searcher.getSimilarity(), reader);
+        };
 
         /**
          * Returns this <code>RangeQuery</code>.

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java?view=diff&rev=526677&r1=526676&r2=526677
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java
Mon Apr  9 02:01:54 2007
@@ -157,12 +157,18 @@
          *
          * @param searcher a <code>Searcher</code> instance.
          */
-        public WildcardQueryWeight(final Searcher searcher) {
-            super(searcher, new ScorerFactory() {
-                public Scorer createScorer(IndexReader reader) {
-                    return new WildcardQueryScorer(searcher.getSimilarity(), reader);
-                }
-            });
+        public WildcardQueryWeight(Searcher searcher) {
+            super(searcher);
+        }
+
+        /**
+         * Creates a {@link WildcardQueryScorer} instance.
+         *
+         * @param reader index reader
+         * @return a {@link WildcardQueryScorer} instance
+         */
+        protected Scorer createScorer(IndexReader reader) {
+            return new WildcardQueryScorer(searcher.getSimilarity(), reader);
         }
 
         /**



Mime
View raw message