Skip to main content
summaryrefslogtreecommitdiffstats
blob: 9bd03f938ac9727b7c59aa6c4eba803ba6477794 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*******************************************************************************
 * Copyright (c) 2012, 2016 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     Sopot Cela - Bug 466829
 *******************************************************************************/
package org.eclipse.help.internal.search;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.br.BrazilianAnalyzer;
import org.apache.lucene.analysis.cjk.CJKAnalyzer;
import org.apache.lucene.analysis.cz.CzechAnalyzer;
import org.apache.lucene.analysis.de.GermanAnalyzer;
import org.apache.lucene.analysis.el.GreekAnalyzer;
import org.apache.lucene.analysis.fr.FrenchAnalyzer;
import org.apache.lucene.analysis.nl.DutchAnalyzer;
import org.apache.lucene.analysis.ru.RussianAnalyzer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExecutableExtension;

/**
 * A factory responsible for instantiating a lucene {@link Analyzer}.
 */
public class AnalyzerFactory implements IExecutableExtension{
	private String locale = null;
	public Analyzer create() {
		if (locale == null)
			return null;
		if ("pt".equals(locale)) //$NON-NLS-1$
			return new BrazilianAnalyzer();
		if ("ja".equals(locale)) //$NON-NLS-1$
			return new CJKAnalyzer();
		if ("ko".equals(locale)) //$NON-NLS-1$
			return new CJKAnalyzer();
		if ("pt".equals(locale)) //$NON-NLS-1$
			return new BrazilianAnalyzer();
		if ("cs".equals(locale)) //$NON-NLS-1$
			return new CzechAnalyzer();
		if ("de".equals(locale)) //$NON-NLS-1$
			return new GermanAnalyzer();
		if ("el".equals(locale)) //$NON-NLS-1$
			return new GreekAnalyzer();
		if ("fr".equals(locale)) //$NON-NLS-1$
			return new FrenchAnalyzer();
		if ("nl".equals(locale)) //$NON-NLS-1$
			return new DutchAnalyzer();
		if ("ru".equals(locale)) //$NON-NLS-1$
			return new RussianAnalyzer();
		//unknown language
		return null;

	}

	@Override
	public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
			throws CoreException {
		if (data instanceof String)
			locale = (String)data;
	}

}

Back to the top