KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lucene > analysis > el > GreekLowerCaseFilter


1 package org.apache.lucene.analysis.el;
2
3 /**
4  * Copyright 2005 The Apache Software Foundation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import org.apache.lucene.analysis.TokenFilter;
20 import org.apache.lucene.analysis.Token;
21 import org.apache.lucene.analysis.TokenStream;
22
23 /**
24  * Normalizes token text to lower case, analyzing given ("greek") charset.
25  *
26  * @author Panagiotis Astithas, past@ebs.gr
27  */

28 public final class GreekLowerCaseFilter extends TokenFilter
29 {
30     char[] charset;
31
32     public GreekLowerCaseFilter(TokenStream in, char[] charset)
33     {
34         super(in);
35         this.charset = charset;
36     }
37
38     public final Token next() throws java.io.IOException JavaDoc
39     {
40         Token t = input.next();
41
42         if (t == null)
43             return null;
44
45         String JavaDoc txt = t.termText();
46
47         char[] chArray = txt.toCharArray();
48         for (int i = 0; i < chArray.length; i++)
49         {
50             chArray[i] = GreekCharsets.toLowerCase(chArray[i], charset);
51         }
52
53         String JavaDoc newTxt = new String JavaDoc(chArray);
54         // create new token
55
Token newToken = new Token(newTxt, t.startOffset(), t.endOffset());
56
57         return newToken;
58     }
59 }
60
Popular Tags