Package org.apache.lucene.analysis.util
Class AbstractAnalysisFactory
java.lang.Object
org.apache.lucene.analysis.util.AbstractAnalysisFactory
- Direct Known Subclasses:
CharFilterFactory,TokenFilterFactory,TokenizerFactory
Abstract parent class for analysis factories
TokenizerFactory,
TokenFilterFactory and CharFilterFactory.
The typical lifecycle for a factory consumer is:
- Create factory via its constructor (or via XXXFactory.forName)
- (Optional) If the factory uses resources such as files,
ResourceLoaderAware.inform(ResourceLoader)is called to initialize those resources. - Consumer calls create() to obtain instances.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractAnalysisFactory(Map<String, String> args) Initialize this factory via a set of key-value pairs. -
Method Summary
Modifier and TypeMethodDescription(package private) static StringgenerateLegacySPIName(Class<? extends AbstractAnalysisFactory> service, String[] suffixes) Deprecated.get(Map<String, String> args, String name, Collection<String> allowedValues, String defaultVal, boolean caseSensitive) protected final booleangetBoolean(Map<String, String> args, String name, boolean defaultVal) charprotected final floatprotected final intgetLines(ResourceLoader loader, String resource) Returns the resource's lines (with content treated as UTF-8)final Versionprotected final PatterngetPattern(Map<String, String> args, String name) Compiles a pattern for the value of the specified argument keynameReturns whitespace- and/or comma-separated set of values, or null if none are foundprotected final CharArraySetgetSnowballWordSet(ResourceLoader loader, String wordFiles, boolean ignoreCase) same asgetWordSet(ResourceLoader, String, boolean), except the input is in snowball format.protected final CharArraySetgetWordSet(ResourceLoader loader, String wordFiles, boolean ignoreCase) Returns asCharArraySetfrom wordFiles, which can be a comma-separated list of filenamesboolean(package private) static StringlookupSPIName(Class<? extends AbstractAnalysisFactory> service) Looks up SPI name (static "NAME" field) with appropriate modifiers.require(Map<String, String> args, String name, Collection<String> allowedValues, boolean caseSensitive) protected final booleanrequireBoolean(Map<String, String> args, String name) charrequireChar(Map<String, String> args, String name) protected final floatrequireFloat(Map<String, String> args, String name) protected final intrequireInt(Map<String, String> args, String name) voidsetExplicitLuceneMatchVersion(boolean isExplicitLuceneMatchVersion) Splits a list separated by zero or more given separator characters.splitFileNames(String fileNames) Splits file names separated by comma character.
-
Field Details
-
LUCENE_MATCH_VERSION_PARAM
- See Also:
-
originalArgs
The original args, before any processing -
luceneMatchVersion
the luceneVersion arg -
isExplicitLuceneMatchVersion
private boolean isExplicitLuceneMatchVersionwhether the luceneMatchVersion arg is explicitly specified in the serialized schema -
ITEM_PATTERN
-
CLASS_NAME
- See Also:
-
-
Constructor Details
-
AbstractAnalysisFactory
Initialize this factory via a set of key-value pairs.
-
-
Method Details
-
getOriginalArgs
-
getLuceneMatchVersion
-
require
-
require
-
require
-
get
-
get
-
get
-
get
-
get
-
requireInt
-
getInt
-
requireBoolean
-
getBoolean
-
requireFloat
-
getFloat
-
requireChar
-
getChar
-
getSet
Returns whitespace- and/or comma-separated set of values, or null if none are found -
getPattern
Compiles a pattern for the value of the specified argument keyname -
getWordSet
protected final CharArraySet getWordSet(ResourceLoader loader, String wordFiles, boolean ignoreCase) throws IOException Returns asCharArraySetfrom wordFiles, which can be a comma-separated list of filenames- Throws:
IOException
-
getLines
Returns the resource's lines (with content treated as UTF-8)- Throws:
IOException
-
getSnowballWordSet
protected final CharArraySet getSnowballWordSet(ResourceLoader loader, String wordFiles, boolean ignoreCase) throws IOException same asgetWordSet(ResourceLoader, String, boolean), except the input is in snowball format.- Throws:
IOException
-
splitFileNames
Splits file names separated by comma character. File names can contain comma characters escaped by backslash '\'- Parameters:
fileNames- the string containing file names- Returns:
- a list of file names with the escaping backslashed removed
-
splitAt
Splits a list separated by zero or more given separator characters. List items can contain comma characters escaped by backslash '\'. Whitespace is NOT trimmed from the returned list items.- Parameters:
list- the string containing the split list items- Returns:
- a list of items with the escaping backslashes removed
-
getClassArg
- Returns:
- the string used to specify the concrete class name in a serialized representation: the class arg.
If the concrete class name was not specified via a class arg, returns
getClass().getName().
-
isExplicitLuceneMatchVersion
public boolean isExplicitLuceneMatchVersion() -
setExplicitLuceneMatchVersion
public void setExplicitLuceneMatchVersion(boolean isExplicitLuceneMatchVersion) -
lookupSPIName
static String lookupSPIName(Class<? extends AbstractAnalysisFactory> service) throws NoSuchFieldException, IllegalAccessException, IllegalStateException Looks up SPI name (static "NAME" field) with appropriate modifiers. Also it must be a String class and declared in the concrete class.- Returns:
- the SPI name
- Throws:
NoSuchFieldException- - if the "NAME" field is not defined.IllegalAccessException- - if the "NAME" field is inaccessible.IllegalStateException- - if the "NAME" field does not have appropriate modifiers or isn't a String field.
-
generateLegacySPIName
@Deprecated static String generateLegacySPIName(Class<? extends AbstractAnalysisFactory> service, String[] suffixes) Deprecated.Generate legacy SPI name derived from the class name.- Returns:
- the SPI name
-