LUCENE-2510: Moved MultiTermComponent into analysis module

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1335876 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Christopher John Male 2012-05-09 01:03:35 +00:00
parent 3fc32fad19
commit 57ee353991
22 changed files with 60 additions and 41 deletions

View File

@ -36,7 +36,7 @@ import java.util.Map;
* Abstract parent class for analysis factories {@link TokenizerFactory}, * Abstract parent class for analysis factories {@link TokenizerFactory},
* {@link TokenFilterFactory} and {@link CharFilterFactory}. * {@link TokenFilterFactory} and {@link CharFilterFactory}.
*/ */
abstract class AbstractAnalysisFactory { public abstract class AbstractAnalysisFactory {
/** The init args */ /** The init args */
protected Map<String,String> args; protected Map<String,String> args;

View File

@ -1,6 +1,6 @@
package org.apache.solr.analysis; package org.apache.lucene.analysis.util;
/** /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
@ -27,5 +27,5 @@ public interface MultiTermAwareComponent {
/** Returns an analysis component to handle analysis if multi-term queries. /** Returns an analysis component to handle analysis if multi-term queries.
* The returned component must be a TokenizerFactory, TokenFilterFactory or CharFilterFactory. * The returned component must be a TokenizerFactory, TokenFilterFactory or CharFilterFactory.
*/ */
public Object getMultiTermComponent(); public AbstractAnalysisFactory getMultiTermComponent();
} }

View File

@ -21,12 +21,10 @@ import java.io.InputStream;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.util.TokenFilterFactory; import org.apache.lucene.analysis.util.*;
import org.apache.lucene.collation.ICUCollationKeyFilter; import org.apache.lucene.collation.ICUCollationKeyFilter;
import org.apache.lucene.analysis.util.ResourceLoader;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.lucene.analysis.util.ResourceLoaderAware;
import com.ibm.icu.text.Collator; import com.ibm.icu.text.Collator;
import com.ibm.icu.text.RuleBasedCollator; import com.ibm.icu.text.RuleBasedCollator;
@ -190,7 +188,7 @@ public class ICUCollationKeyFilterFactory extends TokenFilterFactory implements
} }
@Override @Override
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -2,6 +2,8 @@ package org.apache.solr.analysis;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.icu.ICUFoldingFilter; import org.apache.lucene.analysis.icu.ICUFoldingFilter;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
import org.apache.lucene.analysis.util.TokenFilterFactory; import org.apache.lucene.analysis.util.TokenFilterFactory;
/** /**
@ -29,7 +31,7 @@ public class ICUFoldingFilterFactory extends TokenFilterFactory implements Multi
return new ICUFoldingFilter(input); return new ICUFoldingFilter(input);
} }
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -21,6 +21,8 @@ import java.util.Map;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.icu.ICUNormalizer2Filter; import org.apache.lucene.analysis.icu.ICUNormalizer2Filter;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.lucene.analysis.util.TokenFilterFactory; import org.apache.lucene.analysis.util.TokenFilterFactory;
@ -80,7 +82,7 @@ public class ICUNormalizer2FilterFactory extends TokenFilterFactory implements M
return new ICUNormalizer2Filter(input, normalizer); return new ICUNormalizer2Filter(input, normalizer);
} }
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -21,6 +21,8 @@ import java.util.Map;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.icu.ICUTransformFilter; import org.apache.lucene.analysis.icu.ICUTransformFilter;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.lucene.analysis.util.TokenFilterFactory; import org.apache.lucene.analysis.util.TokenFilterFactory;
@ -66,7 +68,7 @@ public class ICUTransformFilterFactory extends TokenFilterFactory implements Mul
} }
@Override @Override
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -19,6 +19,8 @@
package org.apache.solr.analysis; package org.apache.solr.analysis;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
import org.apache.lucene.analysis.util.TokenFilterFactory; import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilter; import org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilter;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
@ -40,7 +42,7 @@ public class ASCIIFoldingFilterFactory extends TokenFilterFactory implements Mul
} }
@Override @Override
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -18,6 +18,8 @@ package org.apache.solr.analysis;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.ar.ArabicNormalizationFilter; import org.apache.lucene.analysis.ar.ArabicNormalizationFilter;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
import org.apache.lucene.analysis.util.TokenFilterFactory; import org.apache.lucene.analysis.util.TokenFilterFactory;
@ -39,7 +41,7 @@ public class ArabicNormalizationFilterFactory extends TokenFilterFactory impleme
} }
@Override @Override
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -19,6 +19,8 @@ package org.apache.solr.analysis;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.cjk.CJKWidthFilter; import org.apache.lucene.analysis.cjk.CJKWidthFilter;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
import org.apache.lucene.analysis.util.TokenFilterFactory; import org.apache.lucene.analysis.util.TokenFilterFactory;
/** /**
@ -42,7 +44,7 @@ public class CJKWidthFilterFactory extends TokenFilterFactory implements MultiTe
} }
@Override @Override
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -26,11 +26,8 @@ import java.util.Locale;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.util.InitializationException; import org.apache.lucene.analysis.util.*;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.collation.CollationKeyFilter; import org.apache.lucene.collation.CollationKeyFilter;
import org.apache.lucene.analysis.util.ResourceLoader;
import org.apache.lucene.analysis.util.ResourceLoaderAware;
/** /**
* Factory for {@link CollationKeyFilter}. * Factory for {@link CollationKeyFilter}.
@ -172,7 +169,7 @@ public class CollationKeyFilterFactory extends TokenFilterFactory implements Mul
} }
@Override @Override
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -19,6 +19,8 @@ package org.apache.solr.analysis;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.de.GermanNormalizationFilter; import org.apache.lucene.analysis.de.GermanNormalizationFilter;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
import org.apache.lucene.analysis.util.TokenFilterFactory; import org.apache.lucene.analysis.util.TokenFilterFactory;
/** /**
@ -39,7 +41,7 @@ public class GermanNormalizationFilterFactory extends TokenFilterFactory impleme
} }
@Override @Override
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -22,7 +22,9 @@ import java.util.Map;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.el.GreekLowerCaseFilter; import org.apache.lucene.analysis.el.GreekLowerCaseFilter;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.InitializationException; import org.apache.lucene.analysis.util.InitializationException;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
import org.apache.lucene.analysis.util.TokenFilterFactory; import org.apache.lucene.analysis.util.TokenFilterFactory;
/** /**
@ -52,7 +54,7 @@ public class GreekLowerCaseFilterFactory extends TokenFilterFactory implements M
return new GreekLowerCaseFilter(luceneMatchVersion, in); return new GreekLowerCaseFilter(luceneMatchVersion, in);
} }
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -19,6 +19,8 @@ package org.apache.solr.analysis;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.hi.HindiNormalizationFilter; import org.apache.lucene.analysis.hi.HindiNormalizationFilter;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
import org.apache.lucene.analysis.util.TokenFilterFactory; import org.apache.lucene.analysis.util.TokenFilterFactory;
/** /**
@ -38,7 +40,7 @@ public class HindiNormalizationFilterFactory extends TokenFilterFactory implemen
} }
@Override @Override
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -19,6 +19,8 @@ package org.apache.solr.analysis;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.in.IndicNormalizationFilter; import org.apache.lucene.analysis.in.IndicNormalizationFilter;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
import org.apache.lucene.analysis.util.TokenFilterFactory; import org.apache.lucene.analysis.util.TokenFilterFactory;
/** /**
@ -38,7 +40,7 @@ public class IndicNormalizationFilterFactory extends TokenFilterFactory implemen
} }
@Override @Override
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -19,6 +19,8 @@ package org.apache.solr.analysis;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.ga.IrishLowerCaseFilter; import org.apache.lucene.analysis.ga.IrishLowerCaseFilter;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
import org.apache.lucene.analysis.util.TokenFilterFactory; import org.apache.lucene.analysis.util.TokenFilterFactory;
/** /**
@ -41,7 +43,7 @@ public class IrishLowerCaseFilterFactory extends TokenFilterFactory implements M
// this will 'mostly work', except for special cases, just like most other filters // this will 'mostly work', except for special cases, just like most other filters
@Override @Override
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -21,6 +21,8 @@ import java.util.Map;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.core.LowerCaseFilter; import org.apache.lucene.analysis.core.LowerCaseFilter;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
import org.apache.lucene.analysis.util.TokenFilterFactory; import org.apache.lucene.analysis.util.TokenFilterFactory;
/** /**
@ -46,7 +48,7 @@ public class LowerCaseFilterFactory extends TokenFilterFactory implements MultiT
} }
@Override @Override
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -17,8 +17,9 @@
package org.apache.solr.analysis; package org.apache.solr.analysis;
import org.apache.lucene.analysis.core.LowerCaseFilter;
import org.apache.lucene.analysis.core.LowerCaseTokenizer; import org.apache.lucene.analysis.core.LowerCaseTokenizer;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
import org.apache.lucene.analysis.util.TokenizerFactory; import org.apache.lucene.analysis.util.TokenizerFactory;
import java.io.Reader; import java.io.Reader;
@ -46,7 +47,7 @@ public class LowerCaseTokenizerFactory extends TokenizerFactory implements Multi
} }
@Override @Override
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
LowerCaseFilterFactory filt = new LowerCaseFilterFactory(); LowerCaseFilterFactory filt = new LowerCaseFilterFactory();
filt.setLuceneMatchVersion(luceneMatchVersion); filt.setLuceneMatchVersion(luceneMatchVersion);
filt.init(args); filt.init(args);

View File

@ -27,11 +27,8 @@ import java.util.regex.Pattern;
import org.apache.lucene.analysis.CharStream; import org.apache.lucene.analysis.CharStream;
import org.apache.lucene.analysis.charfilter.MappingCharFilter; import org.apache.lucene.analysis.charfilter.MappingCharFilter;
import org.apache.lucene.analysis.charfilter.NormalizeCharMap; import org.apache.lucene.analysis.charfilter.NormalizeCharMap;
import org.apache.lucene.analysis.util.CharFilterFactory; import org.apache.lucene.analysis.util.*;
import org.apache.lucene.analysis.util.InitializationException;
import org.apache.lucene.analysis.util.ResourceLoader;
import org.apache.solr.common.util.StrUtils; import org.apache.solr.common.util.StrUtils;
import org.apache.lucene.analysis.util.ResourceLoaderAware;
/** /**
* Factory for {@link MappingCharFilter}. * Factory for {@link MappingCharFilter}.
@ -131,7 +128,7 @@ public class MappingCharFilterFactory extends CharFilterFactory implements
} }
@Override @Override
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -19,7 +19,9 @@ package org.apache.solr.analysis;
import org.apache.lucene.analysis.CharStream; import org.apache.lucene.analysis.CharStream;
import org.apache.lucene.analysis.fa.PersianCharFilter; import org.apache.lucene.analysis.fa.PersianCharFilter;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.CharFilterFactory; import org.apache.lucene.analysis.util.CharFilterFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
/** /**
* Factory for {@link PersianCharFilter}. * Factory for {@link PersianCharFilter}.
@ -40,7 +42,7 @@ public class PersianCharFilterFactory extends CharFilterFactory implements Multi
} }
@Override @Override
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -21,6 +21,8 @@ package org.apache.solr.analysis;
import org.apache.lucene.analysis.fa.PersianNormalizationFilter; import org.apache.lucene.analysis.fa.PersianNormalizationFilter;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
import org.apache.lucene.analysis.util.TokenFilterFactory; import org.apache.lucene.analysis.util.TokenFilterFactory;
/** /**
@ -41,7 +43,7 @@ public class PersianNormalizationFilterFactory extends TokenFilterFactory implem
} }
@Override @Override
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -19,6 +19,8 @@ package org.apache.solr.analysis;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tr.TurkishLowerCaseFilter; import org.apache.lucene.analysis.tr.TurkishLowerCaseFilter;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
import org.apache.lucene.analysis.util.TokenFilterFactory; import org.apache.lucene.analysis.util.TokenFilterFactory;
/** /**
@ -38,7 +40,7 @@ public class TurkishLowerCaseFilterFactory extends TokenFilterFactory implement
} }
@Override @Override
public Object getMultiTermComponent() { public AbstractAnalysisFactory getMultiTermComponent() {
return this; return this;
} }
} }

View File

@ -19,13 +19,9 @@ package org.apache.solr.schema;
import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.core.KeywordAnalyzer; import org.apache.lucene.analysis.core.KeywordAnalyzer;
import org.apache.lucene.analysis.util.CharFilterFactory; import org.apache.lucene.analysis.util.*;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.analysis.util.TokenizerFactory;
import org.apache.lucene.util.Version; import org.apache.lucene.util.Version;
import org.apache.lucene.analysis.util.ResourceLoader;
import org.apache.solr.analysis.KeywordTokenizerFactory; import org.apache.solr.analysis.KeywordTokenizerFactory;
import org.apache.solr.analysis.MultiTermAwareComponent;
import org.apache.solr.analysis.TokenizerChain; import org.apache.solr.analysis.TokenizerChain;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.apache.solr.util.DOMUtil; import org.apache.solr.util.DOMUtil;
@ -185,7 +181,7 @@ public final class FieldTypePluginLoader
public void add(Object current) { public void add(Object current) {
if (!(current instanceof MultiTermAwareComponent)) return; if (!(current instanceof MultiTermAwareComponent)) return;
Object newComponent = ((MultiTermAwareComponent)current).getMultiTermComponent(); AbstractAnalysisFactory newComponent = ((MultiTermAwareComponent)current).getMultiTermComponent();
if (newComponent instanceof TokenFilterFactory) { if (newComponent instanceof TokenFilterFactory) {
if (filters == null) { if (filters == null) {
filters = new ArrayList<TokenFilterFactory>(2); filters = new ArrayList<TokenFilterFactory>(2);