pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / src / java / org / apache / lucene / analysis / WhitespaceAnalyzer.java
1 package org.apache.lucene.analysis;
2
3 /**
4  * Licensed to the Apache Software Foundation (ASF) under one or more
5  * contributor license agreements.  See the NOTICE file distributed with
6  * this work for additional information regarding copyright ownership.
7  * The ASF licenses this file to You under the Apache License, Version 2.0
8  * (the "License"); you may not use this file except in compliance with
9  * the License.  You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 import java.io.Reader;
21
22 import org.apache.lucene.util.Version;
23
24 /**
25  * An Analyzer that uses {@link WhitespaceTokenizer}.
26  * <p>
27  * <a name="version">You must specify the required {@link Version} compatibility
28  * when creating {@link CharTokenizer}:
29  * <ul>
30  * <li>As of 3.1, {@link WhitespaceTokenizer} uses an int based API to normalize and
31  * detect token codepoints. See {@link CharTokenizer#isTokenChar(int)} and
32  * {@link CharTokenizer#normalize(int)} for details.</li>
33  * </ul>
34  * <p>
35  **/
36 public final class WhitespaceAnalyzer extends ReusableAnalyzerBase {
37   
38   private final Version matchVersion;
39   
40   /**
41    * Creates a new {@link WhitespaceAnalyzer}
42    * @param matchVersion Lucene version to match See {@link <a href="#version">above</a>}
43    */
44   public WhitespaceAnalyzer(Version matchVersion) {
45     this.matchVersion = matchVersion;
46   }
47   
48   /**
49    * Creates a new {@link WhitespaceAnalyzer}
50    * @deprecated use {@link #WhitespaceAnalyzer(Version)} instead 
51    */
52   @Deprecated
53   public WhitespaceAnalyzer() {
54     this(Version.LUCENE_30);
55   }
56   
57   @Override
58   protected TokenStreamComponents createComponents(final String fieldName,
59       final Reader reader) {
60     return new TokenStreamComponents(new WhitespaceTokenizer(matchVersion, reader));
61   }
62 }