Class FilterUtil


  • public class FilterUtil
    extends Object
    • Constructor Detail

      • FilterUtil

        public FilterUtil()
    • Method Detail

      • createFilter

        public static IFilter createFilter​(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​(Class<? extends IFilter> filterClass,
                                           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​(String configId,
                                           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 String addCustomConfig​(FilterConfigurationMapper fcMapper,
                                             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​(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.
      • logDebugEvents

        public static void logDebugEvents​(Iterable<Event> events,
                                          org.slf4j.Logger logger)
        Logs events at the debug level.
        Parameters:
        events - The events to log
        logger - The logger
      • logDebugEvent

        public static void logDebugEvent​(Event e,
                                         String leader,
                                         org.slf4j.Logger logger)
        Logs an event at the debug level.
        Parameters:
        e -
        leader - A short string to print before the event (but after the logger's standard prefix string)
        logger -