]> source.dussan.org Git - archiva.git/commitdiff
Demoted the analyzer into an inner class
authorEdwin L. Punzalan <epunzalan@apache.org>
Tue, 28 Feb 2006 10:05:43 +0000 (10:05 +0000)
committerEdwin L. Punzalan <epunzalan@apache.org>
Tue, 28 Feb 2006 10:05:43 +0000 (10:05 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@381621 13f79535-47bb-0310-9956-ffa450edef68

maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndex.java
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexAnalyzer.java [deleted file]

index 5f0727c01feda0cd69e0ab574475f984be044bd1..c6af1d970a3efd997dd367de80cccc21a5afb45e 100644 (file)
@@ -18,6 +18,8 @@ package org.apache.maven.repository.indexing;
 
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.SimpleAnalyzer;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.CharTokenizer;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.Term;
@@ -25,6 +27,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
 
 import java.io.File;
 import java.io.IOException;
+import java.io.Reader;
 import java.util.Collection;
 
 /**
@@ -289,4 +292,71 @@ public abstract class AbstractRepositoryIndex
     {
         return KEYWORD_FIELDS.contains( field );
     }
+
+    private class ArtifactRepositoryIndexAnalyzer
+        extends Analyzer
+    {
+        private Analyzer defaultAnalyzer;
+
+        /**
+         * constructor to for this analyzer
+         *
+         * @param defaultAnalyzer the analyzer to use as default for the general fields of the artifact indeces
+         */
+        public ArtifactRepositoryIndexAnalyzer( Analyzer defaultAnalyzer )
+        {
+            this.defaultAnalyzer = defaultAnalyzer;
+        }
+
+        /**
+         * Method called by lucence during indexing operations
+         *
+         * @param fieldName the field name that the lucene object is currently processing
+         * @param reader    a Reader object to the index stream
+         * @return an analyzer to specific to the field name or the default analyzer if none is present
+         */
+        public TokenStream tokenStream( String fieldName, Reader reader )
+        {
+            TokenStream tokenStream;
+
+            if ( RepositoryIndex.FLD_VERSION.equals( fieldName ) || RepositoryIndex.FLD_LASTUPDATE.equals( fieldName ) )
+            {
+                tokenStream = new VersionTokenizer( reader );
+            }
+            else
+            {
+                tokenStream = defaultAnalyzer.tokenStream( fieldName, reader );
+            }
+
+            return tokenStream;
+        }
+
+        /**
+         * Class used to tokenize an artifact's version.
+         */
+        private class VersionTokenizer
+            extends CharTokenizer
+        {
+            /**
+             * Constructor with the required reader to the index stream
+             *
+             * @param reader the Reader object of the index stream
+             */
+            VersionTokenizer( Reader reader )
+            {
+                super( reader );
+            }
+
+            /**
+             * method that lucene calls to check tokenization of a stream character
+             *
+             * @param character char currently being processed
+             * @return true if the char is a token, false if the char is a stop char
+             */
+            protected boolean isTokenChar( char character )
+            {
+                return character != '.' && character != '-';
+            }
+        }
+    }
 }
diff --git a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexAnalyzer.java b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexAnalyzer.java
deleted file mode 100644 (file)
index 22dc30a..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-package org.apache.maven.repository.indexing;
-
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.CharTokenizer;
-import org.apache.lucene.analysis.TokenStream;
-
-import java.io.Reader;
-
-/**
- * Class created specifically to index artifacts
- *
- * @author Edwin Punzalan
- */
-public class ArtifactRepositoryIndexAnalyzer
-    extends Analyzer
-{
-    private Analyzer defaultAnalyzer;
-
-    /**
-     * constructor to for this analyzer
-     *
-     * @param defaultAnalyzer the analyzer to use as default for the general fields of the artifact indeces
-     */
-    public ArtifactRepositoryIndexAnalyzer( Analyzer defaultAnalyzer )
-    {
-        this.defaultAnalyzer = defaultAnalyzer;
-    }
-
-    /**
-     * Method called by lucence during indexing operations
-     *
-     * @param fieldName the field name that the lucene object is currently processing
-     * @param reader    a Reader object to the index stream
-     * @return an analyzer to specific to the field name or the default analyzer if none is present
-     */
-    public TokenStream tokenStream( String fieldName, Reader reader )
-    {
-        TokenStream tokenStream;
-
-        if ( RepositoryIndex.FLD_VERSION.equals( fieldName ) || RepositoryIndex.FLD_LASTUPDATE.equals( fieldName ) )
-        {
-            tokenStream = new VersionTokenizer( reader );
-        }
-        else
-        {
-            tokenStream = defaultAnalyzer.tokenStream( fieldName, reader );
-        }
-
-        return tokenStream;
-    }
-
-    /**
-     * Class used to tokenize an artifact's version.
-     */
-    private static class VersionTokenizer
-        extends CharTokenizer
-    {
-        /**
-         * Constructor with the required reader to the index stream
-         *
-         * @param reader the Reader object of the index stream
-         */
-        VersionTokenizer( Reader reader )
-        {
-            super( reader );
-        }
-
-        /**
-         * method that lucene calls to check tokenization of a stream character
-         *
-         * @param character char currently being processed
-         * @return true if the char is a token, false if the char is a stop char
-         */
-        protected boolean isTokenChar( char character )
-        {
-            return character != '.' && character != '-';
-        }
-    }
-}