opennlp.tools.util

## Class BaseToolFactory

- java.lang.Object
- - opennlp.tools.util.BaseToolFactory

- Direct Known Subclasses:
    ChunkerFactory, DoccatFactory, LanguageDetectorFactory, LemmatizerFactory, POSTaggerFactory, SentenceDetectorFactory, TokenizerFactory, TokenNameFinderFactory

      public abstract class BaseToolFactory
      extends Object

  Base class for all tool factories. Extensions of this class should:
  - implement an empty constructor (TODO is it necessary?)
  - implement a constructor that takes the `ArtifactProvider` and calls `BaseToolFactory(Map)`
  - override `createArtifactMap()` and `createArtifactSerializersMap()` methods if necessary.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BaseToolFactory()` All sub-classes should have an empty constructor

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static BaseToolFactory` | `create(Class<? extends BaseToolFactory> factoryClass, ArtifactProvider artifactProvider)`
    `static BaseToolFactory` | `create(String subclassName, ArtifactProvider artifactProvider)`
    `Map<String,Object>` | `createArtifactMap()` Creates a `Map` with pairs of keys and objects.
    `Map<String,ArtifactSerializer>` | `createArtifactSerializersMap()` Creates a `Map` with pairs of keys and `ArtifactSerializer`.
    `Map<String,String>` | `createManifestEntries()` Creates the manifest entries that will be added to the model manifest
    `abstract void` | `validateArtifactMap()` Validates the parsed artifacts.

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

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

- - ### Constructor Detail

    - #### BaseToolFactory

          public BaseToolFactory()

      All sub-classes should have an empty constructor

  - ### Method Detail

    - #### createArtifactSerializersMap

          public Map<String,ArtifactSerializer> createArtifactSerializersMap()

      Creates a `Map` with pairs of keys and `ArtifactSerializer`. The models implementation should call this method from `BaseModel#createArtifactSerializersMap`

      The base implementation will return a `HashMap` that should be populated by sub-classes.

    - #### createArtifactMap

          public Map<String,Object> createArtifactMap()

      Creates a `Map` with pairs of keys and objects. The models implementation should call this constructor that creates a model programmatically.

      The base implementation will return a `HashMap` that should be populated by sub-classes.

    - #### createManifestEntries

          public Map<String,String> createManifestEntries()

      Creates the manifest entries that will be added to the model manifest
      Returns:
        the manifest entries to added to the model manifest

    - #### validateArtifactMap

          public abstract void validateArtifactMap()
                                            throws InvalidFormatException

      Validates the parsed artifacts. If something is not valid subclasses should throw an `InvalidFormatException`. Note: Subclasses should generally invoke super.validateArtifactMap at the beginning of this method.
      Throws:
        `InvalidFormatException`

    - #### create

          public static BaseToolFactory create(String subclassName,
                                               ArtifactProvider artifactProvider)
                                        throws InvalidFormatException

      Throws:
        `InvalidFormatException`

    - #### create

          public static BaseToolFactory create(Class<? extends BaseToolFactory> factoryClass,
                                               ArtifactProvider artifactProvider)
                                        throws InvalidFormatException

      Throws:
        `InvalidFormatException`

Copyright © 2026 The Apache Software Foundation. All rights reserved.