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