AbstractAnalysisFactory (Lucene 10.5.0 core API)
Description: declaration: package: org.apache.lucene.analysis, class: AbstractAnalysisFactory

Package org.apache.lucene.analysis

# Class AbstractAnalysisFactory

java.lang.Object
org.apache.lucene.analysis.AbstractAnalysisFactory

Direct Known Subclasses:
  `CharFilterFactory`, `TokenFilterFactory`, `TokenizerFactory`

public abstract class AbstractAnalysisFactory extends Object
Abstract parent class for analysis factories `TokenizerFactory`, `TokenFilterFactory` and `CharFilterFactory`.

The typical lifecycle for a factory consumer is:

1. Create factory via its constructor (or via XXXFactory.forName)
2. (Optional) If the factory uses resources such as files, `ResourceLoaderAware.inform(ResourceLoader)` is called to initialize those resources.
3. Consumer calls create() to obtain instances.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `LUCENE_MATCH_VERSION_PARAM`
  `protected final Version`
  `luceneMatchVersion`
  the luceneVersion arg

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `AbstractAnalysisFactory()`
  This default ctor is required to be implemented by all subclasses because of service loader (SPI) specification, but it is never called by Lucene.
  `protected`
  `AbstractAnalysisFactory(Map<String,String> args)`
  Initialize this factory via a set of key-value pairs.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected static RuntimeException`
  `defaultCtorException()`
  Helper method to be called from mandatory default constructor of all subclasses to make `ServiceLoader` happy.
  `String`
  `get(Map<String,String> args, String name)`
  `String`
  `get(Map<String,String> args, String name, String defaultVal)`
  `String`
  `get(Map<String,String> args, String name, Collection<String> allowedValues)`
  `String`
  `get(Map<String,String> args, String name, Collection<String> allowedValues, String defaultVal)`
  `String`
  `get(Map<String,String> args, String name, Collection<String> allowedValues, String defaultVal, boolean caseSensitive)`
  `protected final boolean`
  `getBoolean(Map<String,String> args, String name, boolean defaultVal)`
  `char`
  `getChar(Map<String,String> args, String name, char defaultValue)`
  `String`
  `getClassArg()`
  `protected final float`
  `getFloat(Map<String,String> args, String name, float defaultVal)`
  `protected final int`
  `getInt(Map<String,String> args, String name, int defaultVal)`
  `protected final List<String>`
  `getLines(ResourceLoader loader, String resource)`
  Returns the resource's lines (with content treated as UTF-8)
  `final Version`
  `getLuceneMatchVersion()`
  `final Map<String,String>`
  `getOriginalArgs()`
  `protected final Pattern`
  `getPattern(Map<String,String> args, String name)`
  Compiles a pattern for the value of the specified argument key `name`
  `Set<String>`
  `getSet(Map<String,String> args, String name)`
  Returns whitespace- and/or comma-separated set of values, or null if none are found
  `protected final CharArraySet`
  `getSnowballWordSet(ResourceLoader loader, String wordFiles, boolean ignoreCase)`
  same as `getWordSet(ResourceLoader, String, boolean)`, except the input is in snowball format.
  `protected final CharArraySet`
  `getWordSet(ResourceLoader loader, String wordFiles, boolean ignoreCase)`
  Returns as `CharArraySet` from wordFiles, which can be a comma-separated list of filenames
  `boolean`
  `isExplicitLuceneMatchVersion()`
  `String`
  `require(Map<String,String> args, String name)`
  `String`
  `require(Map<String,String> args, String name, Collection<String> allowedValues)`
  `String`
  `require(Map<String,String> args, String name, Collection<String> allowedValues, boolean caseSensitive)`
  `protected final boolean`
  `requireBoolean(Map<String,String> args, String name)`
  `char`
  `requireChar(Map<String,String> args, String name)`
  `protected final float`
  `requireFloat(Map<String,String> args, String name)`
  `protected final int`
  `requireInt(Map<String,String> args, String name)`
  `void`
  `setExplicitLuceneMatchVersion(boolean isExplicitLuceneMatchVersion)`
  `protected final List<String>`
  `splitAt(char separator, String list)`
  Splits a list separated by zero or more given separator characters.
  `protected final List<String>`
  `splitFileNames(String fileNames)`
  Splits file names separated by comma character.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### LUCENE_MATCH_VERSION_PARAM

    public static final String LUCENE_MATCH_VERSION_PARAM
    See Also:
      - Constant Field Values

  - ### luceneMatchVersion

    protected final Version luceneMatchVersion
    the luceneVersion arg

- ## Constructor Details

  - ### AbstractAnalysisFactory

    protected AbstractAnalysisFactory()
    This default ctor is required to be implemented by all subclasses because of service loader (SPI) specification, but it is never called by Lucene.

    Subclass ctors should call: `throw defaultCtorException();`

    Throws:
      `UnsupportedOperationException` - if invoked
    See Also:
      - `defaultCtorException()`
      - `AbstractAnalysisFactory(Map)`

  - ### AbstractAnalysisFactory

    protected AbstractAnalysisFactory(Map<String,String> args)
    Initialize this factory via a set of key-value pairs.

- ## Method Details

  - ### defaultCtorException

    protected static RuntimeException defaultCtorException()
    Helper method to be called from mandatory default constructor of all subclasses to make `ServiceLoader` happy.

    Should be used in subclass ctors like: `throw defaultCtorException();`

    See Also:
      - `AbstractAnalysisFactory()`

  - ### getOriginalArgs

    public final Map<String,String> getOriginalArgs()

  - ### getLuceneMatchVersion

    public final Version getLuceneMatchVersion()

  - ### require

    public String require(Map<String,String> args, String name)

  - ### require

    public String require(Map<String,String> args, String name, Collection<String> allowedValues)

  - ### require

    public String require(Map<String,String> args, String name, Collection<String> allowedValues, boolean caseSensitive)

  - ### get

    public String get(Map<String,String> args, String name)

  - ### get

    public String get(Map<String,String> args, String name, String defaultVal)

  - ### get

    public String get(Map<String,String> args, String name, Collection<String> allowedValues)

  - ### get

    public String get(Map<String,String> args, String name, Collection<String> allowedValues, String defaultVal)

  - ### get

    public String get(Map<String,String> args, String name, Collection<String> allowedValues, String defaultVal, boolean caseSensitive)

  - ### requireInt

    protected final int requireInt(Map<String,String> args, String name)

  - ### getInt

    protected final int getInt(Map<String,String> args, String name, int defaultVal)

  - ### requireBoolean

    protected final boolean requireBoolean(Map<String,String> args, String name)

  - ### getBoolean

    protected final boolean getBoolean(Map<String,String> args, String name, boolean defaultVal)

  - ### requireFloat

    protected final float requireFloat(Map<String,String> args, String name)

  - ### getFloat

    protected final float getFloat(Map<String,String> args, String name, float defaultVal)

  - ### requireChar

    public char requireChar(Map<String,String> args, String name)

  - ### getChar

    public char getChar(Map<String,String> args, String name, char defaultValue)

  - ### getSet

    public Set<String> getSet(Map<String,String> args, String name)
    Returns whitespace- and/or comma-separated set of values, or null if none are found

  - ### getPattern

    protected final Pattern getPattern(Map<String,String> args, String name)
    Compiles a pattern for the value of the specified argument key `name`

  - ### getWordSet

    protected final CharArraySet getWordSet(ResourceLoader loader, String wordFiles, boolean ignoreCase) throws IOException
    Returns as `CharArraySet` from wordFiles, which can be a comma-separated list of filenames
    Throws:
      `IOException`

  - ### getLines

    protected final List<String> getLines(ResourceLoader loader, String resource) throws IOException
    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 as `getWordSet(ResourceLoader, String, boolean)`, except the input is in snowball format.
    Throws:
      `IOException`

  - ### splitFileNames

    protected final List<String> splitFileNames(String fileNames)
    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

    protected final List<String> splitAt(char separator, String list)
    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

    public String 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)