@Override public IFilter createFilter (String configId) { return createFilter(configId, null); }
public void addCustomConfiguration (String configId, IParameters parameters) { FilterConfiguration fc; fc = new FilterConfiguration(); fc.custom = true; fc.configId = configId; // Get the filter String[] res = splitFilterFromConfiguration(fc.configId); if ( res == null ) { // Cannot found the filter in the ID LOGGER.error("Cannot find filter ID in: {}. Cannot add configuration", configId); return; } // Create the filter (this assumes the base-name is the default config ID) tmpFilter = createFilter(res[0], tmpFilter); if ( tmpFilter == null ) { LOGGER.error("Cannot find filter with ID: {}. Cannot add configuration", res[0]); return; } // Set the data //fc.classLoader = (URLClassLoader) tmpFilter.getClass().getClassLoader(); fc.parametersLocation = fc.configId + CONFIGFILE_EXT; fc.filterClass = tmpFilter.getClass().getName(); fc.mimeType = tmpFilter.getMimeType(); fc.description = "Configuration "+fc.configId; // Temporary fc.name = fc.configId; // Temporary fc.parameters = parameters; addConfiguration(fc); }
/** * Creates an instance of the filter for a given URL of a fprm file defining a * custom configuration. * @param 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". * @return a new {@link IFilter} object (with its parameters loaded) for the given * configuration identifier, or null if the object could not be created. */ public static IFilter createFilter(URL customConfig) { FilterConfigurationMapper fcMapper = new FilterConfigurationMapper(); DefaultFilters.setMappings(fcMapper, true, true); return fcMapper.createFilter(addCustomConfig(fcMapper, customConfig)); }
/** * 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. * @param 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. * @param 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. * @return a new {@link IFilter} object (with its parameters loaded) for the given * configuration identifier, or null if the object could not be created. */ public static IFilter createFilter(String configId, URL... customConfigs) { FilterConfigurationMapper fcMapper = new FilterConfigurationMapper(); DefaultFilters.setMappings(fcMapper, true, true); for (URL customConfig : customConfigs) { addCustomConfig(fcMapper, customConfig); } IFilter filter = fcMapper.createFilter(configId); filter.setFilterConfigurationMapper(fcMapper); return filter; }