org.apache.lucene.analysis.util

## Class AbstractAnalysisFactory

- java.lang.Object
- - org.apache.lucene.analysis.util.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 a no-arg constructor
  2. Set version emulation by calling `setLuceneMatchVersion(Version)`
  3. Calls `init(Map)` passing arguments as key-value mappings.
  4. (Optional) If the factory uses resources such as files, `ResourceLoaderAware.inform(ResourceLoader)` is called to initialize those resources.
  5. Consumer calls create() to obtain instances.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Map<String,String>` | `args` The init args
    `protected Version` | `luceneMatchVersion` the luceneVersion arg

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractAnalysisFactory()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `assureMatchVersion()` this method can be called in the `TokenizerFactory.create(java.io.Reader)` or `TokenFilterFactory.create(org.apache.lucene.analysis.TokenStream)` methods, to inform user, that for this factory a `luceneMatchVersion` is required
    `Map<String,String>` | `getArgs()`
    `protected boolean` | `getBoolean(String name, boolean defaultVal)`
    `protected boolean` | `getBoolean(String name, boolean defaultVal, boolean useDefault)`
    `protected int` | `getInt(String name)`
    `protected int` | `getInt(String name, int defaultVal)`
    `protected int` | `getInt(String name, int defaultVal, boolean useDefault)`
    `protected List<String>` | `getLines(ResourceLoader loader, String resource)` Returns the resource's lines (with content treated as UTF-8)
    `Version` | `getLuceneMatchVersion()`
    `Map<String,String>` | `getOriginalArgs()`
    `protected Pattern` | `getPattern(String name)` Compiles a pattern for the value of the specified argument key `name`
    `protected CharArraySet` | `getSnowballWordSet(ResourceLoader loader, String wordFiles, boolean ignoreCase)` same as `getWordSet(ResourceLoader, String, boolean)`, except the input is in snowball format.
    `protected CharArraySet` | `getWordSet(ResourceLoader loader, String wordFiles, boolean ignoreCase)` Returns as `CharArraySet` from wordFiles, which can be a comma-separated list of filenames
    `void` | `init(Map<String,String> args)` Initialize this factory via a set of key-value pairs.
    `void` | `setLuceneMatchVersion(Version luceneMatchVersion)`
    `protected 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 Detail

    - #### args

          protected Map<String,String> args

      The init args

    - #### luceneMatchVersion

          protected Version luceneMatchVersion

      the luceneVersion arg

  - ### Constructor Detail

    - #### AbstractAnalysisFactory

          public AbstractAnalysisFactory()

  - ### Method Detail

    - #### init

          public void init(Map<String,String> args)

      Initialize this factory via a set of key-value pairs.

    - #### getArgs

          public Map<String,String> getArgs()

    - #### getOriginalArgs

          public Map<String,String> getOriginalArgs()

    - #### assureMatchVersion

          protected final void assureMatchVersion()

      this method can be called in the `TokenizerFactory.create(java.io.Reader)` or `TokenFilterFactory.create(org.apache.lucene.analysis.TokenStream)` methods, to inform user, that for this factory a `luceneMatchVersion` is required

    - #### setLuceneMatchVersion

          public void setLuceneMatchVersion(Version luceneMatchVersion)

    - #### getLuceneMatchVersion

          public Version getLuceneMatchVersion()

    - #### getInt

          protected int getInt(String name)

    - #### getInt

          protected int getInt(String name,
                   int defaultVal)

    - #### getInt

          protected int getInt(String name,
                   int defaultVal,
                   boolean useDefault)

    - #### getBoolean

          protected boolean getBoolean(String name,
                           boolean defaultVal)

    - #### getBoolean

          protected boolean getBoolean(String name,
                           boolean defaultVal,
                           boolean useDefault)

    - #### getPattern

          protected Pattern getPattern(String name)

      Compiles a pattern for the value of the specified argument key `name`

    - #### getWordSet

          protected 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 List<String> getLines(ResourceLoader loader,
                              String resource)
                                   throws IOException

      Returns the resource's lines (with content treated as UTF-8)
      Throws:
        `IOException`

    - #### getSnowballWordSet

          protected 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 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

Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.