All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.search.cfg.NormalizerDefMapping Maven / Gradle / Ivy

There is a newer version: 5.11.12.Final
Show newest version
/*
 * Hibernate Search, full-text search for your domain model
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.search.cfg;

import java.util.HashMap;
import java.util.Map;

import org.apache.lucene.analysis.util.CharFilterFactory;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.analysis.util.TokenizerFactory;

/**
 * @author Emmanuel Bernard
 */
public class NormalizerDefMapping {
	private SearchMapping mapping;
	private Map definition;

	NormalizerDefMapping(String name, SearchMapping mapping) {
		this.mapping = mapping;
		this.definition = new HashMap();
		mapping.addNormalizerDef( definition );
		definition.put( "name", name );
	}

	/**
	 * {@code @CharFilterDef(factory=factory) }
	 * @param factory the {@link CharFilterFactory}
	 * @return a new {@link CharFilterDefMapping}
	 */
	public CharFilterDefMapping charFilter(Class factory) {
		return charFilter( "", factory );
	}

	/**
	 * {@code @CharFilterDef(name=name, factory=factory) }
	 * @param name the char filter name
	 * @param factory the {@link CharFilterFactory}
	 * @return a new {@link CharFilterDefMapping}
	 */
	public CharFilterDefMapping charFilter(String name, Class factory) {
		return new CharFilterDefMapping( name, factory, definition, mapping );
	}

	/**
	 * {@code @TokenFilterDef(factory=factory) }
	 * @param factory the {@link TokenFilterFactory}
	 * @return a new {@link TokenFilterDefMapping}
	 */
	public TokenFilterDefMapping filter(Class factory) {
		return filter( "", factory );
	}

	/**
	 * {@code @TokenFilterDef(name=name, factory=factory) }
	 * @param name the token filter name
	 * @param factory the {@link TokenFilterFactory}
	 * @return a new {@link TokenFilterDefMapping}
	 */
	public TokenFilterDefMapping filter(String name, Class factory) {
		return new TokenFilterDefMapping( factory, definition, mapping );
	}

	public AnalyzerDefMapping analyzerDef(String name, Class tokenizerFactory) {
		return analyzerDef( name, "", tokenizerFactory );
	}

	public AnalyzerDefMapping analyzerDef(String name, String tokenizerName, Class tokenizerFactory) {
		return new AnalyzerDefMapping( name, tokenizerName, tokenizerFactory, mapping );
	}

	public NormalizerDefMapping normalizerDef(String name) {
		return new NormalizerDefMapping( name, mapping );
	}

	public EntityMapping entity(Class entityType) {
		return new EntityMapping( entityType, mapping );
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy