jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r312842 - /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
Date Tue, 11 Oct 2005 08:46:42 GMT
Author: jukka
Date: Tue Oct 11 01:46:37 2005
New Revision: 312842

URL: http://svn.apache.org/viewcvs?rev=312842&view=rev
Log:
JCR-220: Added a setter method for the Lucene Analyzer property.

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java?rev=312842&r1=312841&r2=312842&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
Tue Oct 11 01:46:37 2005
@@ -76,7 +76,7 @@
     /**
      * The analyzer we use for indexing.
      */
-    private final Analyzer analyzer;
+    private Analyzer analyzer;
 
     /**
      * The location of the search index.
@@ -330,6 +330,34 @@
      */
     Analyzer getAnalyzer() {
         return analyzer;
+    }
+
+    /**
+     * Sets the analyzer in use for indexing. The given analyzer class name
+     * must satisfy the following conditions:
+     * <ul>
+     *   <li>the class must exist in the class path</li>
+     *   <li>the class must have a public default constructor</li>
+     *   <li>the class must be a Lucene Analyzer</li> 
+     * </ul>
+     * <p>
+     * If the above conditions are met, then a new instance of the class is
+     * set as the analyzer. Otherwise a warning is logged and the current
+     * analyzer is not changed.
+     * <p>
+     * This property setter method is normally invoked by the Jackrabbit
+     * configuration mechanism if the "analyzer" parameter is set in the
+     * search configuration. 
+     *
+     * @param analyzerClassName the analyzer class name
+     */
+    public void setAnalyzer(String analyzerClassName) {
+        try {
+            Class analyzerClass = Class.forName(analyzerClassName);
+            analyzer = (Analyzer) analyzerClass.newInstance();
+        } catch (Exception e) {
+            log.warn("Invalid Analyzer class: " + analyzerClassName, e);
+        }
     }
 
     /**



Mime
View raw message