01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.solr.analysis;
17:
18: import org.apache.lucene.analysis.TokenStream;
19:
20: import java.util.Map;
21:
22: /**
23: * A <code>TokenFilterFactory</code> creates a
24: * <code>TokenFilter</code> to transform one <code>TokenStream</code>
25: * into another.
26: *
27: * <p>
28: * TokenFilterFactories are registered for <code>FieldType</code>s with the
29: * <code>IndexSchema</code> through the <code>schema.xml</code> file.
30: * </p>
31: * <p>
32: * Example <code>schema.xml</code> entry to register a TokenFilterFactory
33: * implementation to transform tokens in a field of type "cool"
34: * </p>
35: * <pre>
36: * <fieldtype name="cool" class="solr.TextField">
37: * <analyzer>
38: * ...
39: * <filter class="foo.MyTokenFilterFactory"/>
40: * ...
41: * </pre>
42: * <p>
43: * A single instance of any registered TokenFilterFactory is created
44: * via the default constructor and is reused for each FieldType.
45: * </p>
46: * @author yonik
47: * @version $Id: TokenFilterFactory.java 533579 2007-04-30 03:58:02Z ehatcher $
48: */
49:
50: public interface TokenFilterFactory {
51: /** <code>init</code> will be called just once, immediately after creation.
52: * <p>The args are user-level initialization parameters that
53: * may be specified when declaring a the factory in the
54: * schema.xml
55: */
56: public void init(Map<String, String> args);
57:
58: /**
59: * Accessor method for reporting the args used to initialize this factory.
60: * <p>
61: * Implementations are <strong>strongly</strong> encouraged to return
62: * the contents of the Map passed to to the init method
63: * </p>
64: */
65: public Map<String, String> getArgs();
66:
67: /** Transform the specified input TokenStream */
68: public TokenStream create(TokenStream input);
69: }
|