net.sf.okapi.common.filters

## Class FilterUtil

- java.lang.Object
- - net.sf.okapi.common.filters.FilterUtil

-     public class FilterUtil
      extends java.lang.Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FilterUtil()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `addCustomConfig(FilterConfigurationMapper fcMapper, java.net.URL customConfig)` Adds to a given `FilterConfigurationMapper` object the custom configuration defined in the fprm file denoted by a given URL.
    `static Event` | `createCodeSimplifierEvent(java.lang.String rules)` Generate `Custom` `Event` for code simplifier rules.
    `static IFilter` | `createFilter(java.lang.Class<? extends IFilter> filterClass, java.lang.String configId)` Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters.
    `static IFilter` | `createFilter(java.lang.String configId)` Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters.
    `static IFilter` | `createFilter(java.lang.String configId, java.net.URL... customConfigs)` Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters.
    `static IFilter` | `createFilter(java.net.URL customConfig)` Creates an instance of the filter for a given URL of a fprm file defining a custom configuration.

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

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

- - ### Constructor Detail

    - #### FilterUtil

          public FilterUtil()

  - ### Method Detail

    - #### createCodeSimplifierEvent

          public static final Event createCodeSimplifierEvent(java.lang.String rules)

      Generate `Custom` `Event` for code simplifier rules.
      Parameters:
        `rules` - - simplifier rules as a single string.
      Returns:
        - `Event` with `Custom` resource and `SimplifierRulesAnnotaton`.

    - #### createFilter

          public static IFilter createFilter(java.lang.String configId)

      Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters. Only Okapi default filter configurations are accepted.
      Parameters:
        `configId` - the filter configuration identifier. Can only be one of default filter configurations.
      Returns:
        a new `IFilter` object (with its parameters loaded) for the given configuration identifier, or null if the object could not be created.

    - #### createFilter

          public static IFilter createFilter(java.lang.Class<? extends IFilter> filterClass,
                             java.lang.String configId)

      Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters.
      Parameters:
        `filterClass` - class of the filter.
        `configId` - the filter configuration identifier. Can be either one of Okapi default filter configurations or one of the built-in configurations defined in the filter class.
      Returns:
        a new `IFilter` object (with its parameters loaded) for the given configuration identifier, or null if the object could not be created.

    - #### createFilter

          public static IFilter createFilter(java.lang.String configId,
                             java.net.URL... customConfigs)

      Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters. This method accepts a list of the URLs of fprm files defining custom configurations, and can be used to create a filter and configure its sub-filters in one call.
      Parameters:
        `configId` - the filter configuration identifier. Can be either one of Okapi default filter configurations or one of the custom configurations defined in the fprm files.
        `customConfigs` - a list of the URLs of fprm files defining custom configurations. Every file name should follow the pattern of custom filter configurations, i.e. contain a filter name like "okf_xmlstream@custom_config.fprm". The file extension should be .fprm.
      Returns:
        a new `IFilter` object (with its parameters loaded) for the given configuration identifier, or null if the object could not be created.

    - #### addCustomConfig

          public static java.lang.String addCustomConfig(FilterConfigurationMapper fcMapper,
                                         java.net.URL customConfig)

      Adds to a given `FilterConfigurationMapper` object the custom configuration defined in the fprm file denoted by a given URL.
      Parameters:
        `fcMapper` - the given `FilterConfigurationMapper`.
        `customConfig` - the URL of a fprm file defining the custom configuration the filter should be loaded from. The file extension should be .fprm. The file name should follow the pattern of custom filter configurations, i.e. contain a filter name like "okf_xmlstream@custom_config.fprm".
      Returns:
        the configuration identifier or null if the configuration was not added.

    - #### createFilter

          public static IFilter createFilter(java.net.URL customConfig)

      Creates an instance of the filter for a given URL of a fprm file defining a custom configuration.
      Parameters:
        `customConfig` - the URL of a fprm file defining the custom configuration the filter should be loaded from. The file extension should be .fprm. The file name should follow the pattern of custom filter configurations, i.e. contain a filter name like "okf_xmlstream@custom_config.fprm".
      Returns:
        a new `IFilter` object (with its parameters loaded) for the given configuration identifier, or null if the object could not be created.