CompatibleAnalyser.java revision 392
1923N/A/*
1923N/A * CDDL HEADER START
1923N/A *
1923N/A * The contents of this file are subject to the terms of the
1923N/A * Common Development and Distribution License (the "License").
1923N/A * You may not use this file except in compliance with the License.
1923N/A *
1923N/A * See LICENSE.txt included in this distribution for the specific
1923N/A * language governing permissions and limitations under the License.
1923N/A *
1923N/A * When distributing Covered Code, include this CDDL HEADER in each
1923N/A * file and include the License file at LICENSE.txt.
1923N/A * If applicable, add the following below this CDDL HEADER, with the
1923N/A * fields enclosed by brackets "[]" replaced with your own identifying
1923N/A * information: Portions Copyright [yyyy] [name of copyright owner]
1923N/A *
1923N/A * CDDL HEADER END
1923N/A */
1923N/A
1923N/A/*
1923N/A * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
1923N/A * Use is subject to license terms.
3996N/A */
1923N/Apackage org.opensolaris.opengrok.analysis;
1923N/A
1923N/Aimport java.io.Reader;
1923N/Aimport org.apache.lucene.analysis.Analyzer;
1923N/Aimport org.apache.lucene.analysis.TokenStream;
1923N/Aimport org.opensolaris.opengrok.analysis.plain.PlainFullTokenizer;
1923N/Aimport org.opensolaris.opengrok.analysis.plain.PlainSymbolTokenizer;
1923N/A
1923N/Apublic class CompatibleAnalyser extends Analyzer {
1923N/A PathAnalyzer pather;
1923N/A HistoryAnalyzer historer;
1923N/A
1923N/A public CompatibleAnalyser() {
1923N/A historer = new HistoryAnalyzer();
1923N/A pather = new PathAnalyzer();
1923N/A }
1923N/A
1923N/A public TokenStream tokenStream(String fieldName, Reader reader) {
1923N/A if (fieldName.equals("full")) {
1923N/A return new PlainFullTokenizer(reader);
1923N/A } else if (fieldName.equals("refs")) {
1923N/A return new PlainSymbolTokenizer(reader);
1923N/A } else if (fieldName.equals("defs")) {
1923N/A return new PlainSymbolTokenizer(reader);
1923N/A } else if (fieldName.equals("path") || fieldName.equals("project")) {
1923N/A return pather.tokenStream(fieldName, reader);
3661N/A } else if (fieldName.equals("hist")) {
3661N/A return historer.tokenStream(fieldName, reader);
3996N/A }
3996N/A return new PlainFullTokenizer(reader);
3996N/A }
1923N/A}
1923N/A