org.apache.uima.fit.factory

## Class ConfigurationParameterFactory

- java.lang.Object
- - org.apache.uima.fit.factory.ConfigurationParameterFactory

-     public final class ConfigurationParameterFactory
      extends Object

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ConfigurationParameterFactory.ConfigurationData` A simple class for storing an array of configuration parameters along with an array of the values that will fill in those configuration parameters

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addConfigurationParameter(org.apache.uima.resource.ResourceCreationSpecifier specifier, String name, Object value)` Adds a single configuration parameter name value pair to a specifier
    `static void` | `addConfigurationParameters(org.apache.uima.resource.ResourceCreationSpecifier specifier, Class<?>... dynamicallyLoadedClasses)` Provides a mechanism to add configuration parameter information to a specifier for the given classes.
    `static void` | `addConfigurationParameters(org.apache.uima.resource.ResourceCreationSpecifier specifier, List<Class<?>> dynamicallyLoadedClasses)` Provides a mechanism to add configuration parameter information to a specifier for the given classes.
    `static void` | `addConfigurationParameters(org.apache.uima.resource.ResourceCreationSpecifier specifier, Object... configurationData)` This method adds configuration parameter information to the specifier given the provided configuration data
    `static boolean` | `canParameterBeSet(org.apache.uima.resource.ResourceSpecifier aSpec, String name)` Check if the given parameter can be set on the provided specifier.
    `protected static Object` | `convertParameterValue(org.apache.uima.resource.metadata.ConfigurationParameter param, Object aValue)` Convert a value so it can be injected into a UIMA component.
    `static ConfigurationParameterFactory.ConfigurationData` | `createConfigurationData(Class<?> componentClass)` This method creates configuration data for a given class definition using reflection and the configuration parameter annotation
    `static ConfigurationParameterFactory.ConfigurationData` | `createConfigurationData(Object... configurationData)` This method converts configuration data provided as an array of objects and returns a `ConfigurationParameterFactory.ConfigurationData` object.
    `static org.apache.uima.resource.metadata.ConfigurationParameter` | `createPrimitiveParameter(Field field)` A factory method for creating a ConfigurationParameter from a given field definition
    `static org.apache.uima.resource.metadata.ConfigurationParameter` | `createPrimitiveParameter(String name, Class<?> parameterClass, String parameterDescription, boolean isMandatory)` A factory method for creating a ConfigurationParameter object.
    `static org.apache.uima.resource.metadata.ConfigurationParameter` | `createPrimitiveParameter(String name, String parameterType, String parameterDescription, boolean isMultiValued, boolean isMandatory)` A factory method for creating a ConfigurationParameter object.
    `static String` | `getConfigurationParameterName(Field field)` This method generates the default name of a configuration parameter that is defined by an `ConfigurationParameter` annotation when no name is given
    `static Object` | `getDefaultValue(Field field)` Determines the default value of an annotated configuration parameter.
    `static Map<String,Object>` | `getParameterSettings(org.apache.uima.resource.ResourceSpecifier spec)` Fetches the parameter settings from the given resource specifier.
    `static boolean` | `isConfigurationParameterField(Field field)` This method determines if the field is annotated with `ConfigurationParameter`.
    `static void` | `setParameter(org.apache.uima.resource.ResourceSpecifier aSpec, String name, Object value)` Sets the specified parameter in the given resource specifier.
    `static void` | `setParameters(org.apache.uima.resource.ResourceCreationSpecifier desc, Class<?> componentClass, org.apache.uima.resource.metadata.ConfigurationParameter[] configurationParameters, Object[] configurationValues)` Analyze a component for parameters and default values, merge that with parameter values specified, potentially adding extra parameters.

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

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

- - ### Method Detail

    - #### isConfigurationParameterField

          public static boolean isConfigurationParameterField(Field field)

      This method determines if the field is annotated with `ConfigurationParameter`.
      Parameters:
        `field` - the field to analyze
      Returns:
        whether the field is marked as a configuration parameter

    - #### getDefaultValue

          public static Object getDefaultValue(Field field)

      Determines the default value of an annotated configuration parameter. The returned value is not necessarily the value that the annotated member variable will be instantiated with in ConfigurationParameterInitializer which does extra work to convert the UIMA configuration parameter value to comply with the type of the member variable.
      Parameters:
        `field` - the field to analyze
      Returns:
        the default value

    - #### getConfigurationParameterName

          public static String getConfigurationParameterName(Field field)

      This method generates the default name of a configuration parameter that is defined by an `ConfigurationParameter` annotation when no name is given
      Parameters:
        `field` - the field to analyze
      Returns:
        the parameter name

    - #### createPrimitiveParameter

          public static org.apache.uima.resource.metadata.ConfigurationParameter createPrimitiveParameter(Field field)

      A factory method for creating a ConfigurationParameter from a given field definition
      Parameters:
        `field` - the field to analyze
      Returns:
        the configuration parameter.

    - #### createPrimitiveParameter

          public static org.apache.uima.resource.metadata.ConfigurationParameter createPrimitiveParameter(String name,
                                                                                                          Class<?> parameterClass,
                                                                                                          String parameterDescription,
                                                                                                          boolean isMandatory)

      A factory method for creating a ConfigurationParameter object.
      Parameters:
        `name` - the parameter name
        `parameterClass` - the parameter class
        `parameterDescription` - the parameter description
        `isMandatory` - whether the parameter is mandatory
      Returns:
        the configuration parameter

    - #### convertParameterValue

          protected static Object convertParameterValue(org.apache.uima.resource.metadata.ConfigurationParameter param,
                                                        Object aValue)

      Convert a value so it can be injected into a UIMA component. UIMA only supports several parameter types. If the value is not of these types, this method can be used to coerce the value into a supported type (typically String). It is also used to convert primitive arrays to object arrays when necessary.
      Parameters:
        `param` - the configuration parameter.
        `aValue` - the parameter value.
      Returns:
        the converted value.

    - #### createPrimitiveParameter

          public static org.apache.uima.resource.metadata.ConfigurationParameter createPrimitiveParameter(String name,
                                                                                                          String parameterType,
                                                                                                          String parameterDescription,
                                                                                                          boolean isMultiValued,
                                                                                                          boolean isMandatory)

      A factory method for creating a ConfigurationParameter object.
      Parameters:
        `name` - the parameter name
        `parameterType` - the parameter type
        `parameterDescription` - the parameter description
        `isMultiValued` - whether the parameter is multi-valued
        `isMandatory` - whether the parameter is mandatory
      Returns:
        the configuration parameter

    - #### setParameters

          public static void setParameters(org.apache.uima.resource.ResourceCreationSpecifier desc,
                                           Class<?> componentClass,
                                           org.apache.uima.resource.metadata.ConfigurationParameter[] configurationParameters,
                                           Object[] configurationValues)

      Analyze a component for parameters and default values, merge that with parameter values specified, potentially adding extra parameters. Set the merged result into the provided descriptor.
      Parameters:
        `desc` - the descriptor into which to merge the parameters
        `componentClass` - the component class which will be analyzed for parameters. Must match the implementationName set in the descriptor.
        `configurationParameters` - additional parameter names
        `configurationValues` - additional parameters values

    - #### createConfigurationData

          public static ConfigurationParameterFactory.ConfigurationData createConfigurationData(Object... configurationData)

      This method converts configuration data provided as an array of objects and returns a `ConfigurationParameterFactory.ConfigurationData` object. This should only be used to prepare values supplied in a factory method call for merging with existing parameter declarations, e.g. extracted from a class using `createConfigurationData(Class)`.
      Parameters:
        `configurationData` - configuration parameters as (name, value) pairs, so there should always be an even number of parameters.
      Returns:
        the configuration data

    - #### createConfigurationData

          public static ConfigurationParameterFactory.ConfigurationData createConfigurationData(Class<?> componentClass)

      This method creates configuration data for a given class definition using reflection and the configuration parameter annotation
      Parameters:
        `componentClass` - the class to analyze
      Returns:
        the configuration settings extracted from the class

    - #### addConfigurationParameters

          public static void addConfigurationParameters(org.apache.uima.resource.ResourceCreationSpecifier specifier,
                                                        Object... configurationData)

      This method adds configuration parameter information to the specifier given the provided configuration data
      Parameters:
        `specifier` - the specified to add the parameters to
        `configurationData` - should consist of name value pairs.

    - #### addConfigurationParameters

          public static void addConfigurationParameters(org.apache.uima.resource.ResourceCreationSpecifier specifier,
                                                        List<Class<?>> dynamicallyLoadedClasses)

      Provides a mechanism to add configuration parameter information to a specifier for the given classes. This method may be useful in situations where a class definition has annotated configuration parameters that you want to include in the given specifier.
      Parameters:
        `specifier` - the specified to add the parameters to
        `dynamicallyLoadedClasses` - the classes to analyze and extract parameter information from

    - #### addConfigurationParameters

          public static void addConfigurationParameters(org.apache.uima.resource.ResourceCreationSpecifier specifier,
                                                        Class<?>... dynamicallyLoadedClasses)

      Provides a mechanism to add configuration parameter information to a specifier for the given classes. This method may be useful in situations where a class definition has annotated configuration parameters that you want to include in the given specifier
      Parameters:
        `specifier` - the specified to add the parameters to
        `dynamicallyLoadedClasses` - the classes to analyze and extract parameter information from

    - #### addConfigurationParameter

          public static void addConfigurationParameter(org.apache.uima.resource.ResourceCreationSpecifier specifier,
                                                       String name,
                                                       Object value)

      Adds a single configuration parameter name value pair to a specifier
      Parameters:
        `specifier` - the specifier to add the parameter setting to
        `name` - the name of the parameter
        `value` - the parameter value

    - #### getParameterSettings

          public static Map<String,Object> getParameterSettings(org.apache.uima.resource.ResourceSpecifier spec)

      Fetches the parameter settings from the given resource specifier.
      Parameters:
        `spec` - a resource specifier.
      Returns:
        the parameter settings.

    - #### setParameter

          public static void setParameter(org.apache.uima.resource.ResourceSpecifier aSpec,
                                          String name,
                                          Object value)

      Sets the specified parameter in the given resource specifier. If the specified is a `CustomResourceSpecifier` an exception is thrown if the parameter value not a String.
      Parameters:
        `aSpec` - a resource specifier.
        `name` - the parameter name.
        `value` - the parameter value.
      Throws:
        `org.apache.commons.lang.IllegalClassException` - if the value is not of a supported type for the given specifier.

    - #### canParameterBeSet

          public static boolean canParameterBeSet(org.apache.uima.resource.ResourceSpecifier aSpec,
                                                  String name)

      Check if the given parameter can be set on the provided specifier. Some specifier types require parameters to be declared before they can be set.
      Parameters:
        `aSpec` - the specifier to test
        `name` - the parameter to be tested
      Returns:
        if the parameter can be set

Copyright © 2012–2020 The Apache Software Foundation. All rights reserved.