Package net.sf.okapi.common.filters
Class FilterConfigurationMapper
- java.lang.Object
-
- net.sf.okapi.common.ParametersEditorMapper
-
- net.sf.okapi.common.filters.FilterConfigurationMapper
-
- All Implemented Interfaces:
Iterable<FilterConfiguration>,IFilterConfigurationMapper,IParametersEditorMapper
@Deprecated public class FilterConfigurationMapper extends ParametersEditorMapper implements IFilterConfigurationMapper
Deprecated.This class will be moved to okapi-ui and replaced withThreadSafeFilterConfigurationMapperWARNING: Resource intensive and not thread safe.UI or non-server oriented implementation of the
IFilterConfigurationMapperinterface that uses the local filesystem to access custom configurations. In this implementation the custom configurations are stored as simple files in the file system of the machine and the value forFilterConfiguration.parametersLocationfor a custom configuration is filename of the parameters file. The directory where the files are located is defined with thesetCustomConfigurationsDirectory(String).
-
-
Field Summary
-
Fields inherited from class net.sf.okapi.common.ParametersEditorMapper
descMap, editorMap
-
Fields inherited from interface net.sf.okapi.common.filters.IFilterConfigurationMapper
CONFIGFILE_EXT, CONFIGFILE_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description FilterConfigurationMapper()Deprecated.Creates a new FilterConfigurationMapper object with no mappings and the custom configuration directory set to the current directory.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddConfiguration(FilterConfiguration config)Deprecated.Adds a new configuration to this mapper.voidaddConfigurations(String filterClass)Deprecated.Adds all the predefined configurations of a given filter to this mapper.voidaddCustomConfiguration(String configId, String parameters)Deprecated.Add a customFilterConfigurationwithIParametersvoidaddCustomConfiguration(String configId, IParameters parameters)Deprecated.Add a customFilterConfigurationwithIParametersvoidaddFromPlugins(PluginsManager pm)Deprecated.voidclearConfigurations(boolean customOnly)Deprecated.Removes configuration mappings from this mapper.IParametersEditorcreateConfigurationEditor(String configId)Deprecated.Creates an instance of the filter's parameters editor for a given configuration identifier.IParametersEditorcreateConfigurationEditor(String configId, IFilter existingFilter)Deprecated.Creates an instance of the filter's parameters editor for a given configuration identifier.FilterConfigurationcreateCustomConfiguration(FilterConfiguration baseConfig)Deprecated.Creates a custom configuration object based on a give one.IFiltercreateFilter(String configId)Deprecated.Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters.IFiltercreateFilter(String configId, IFilter existingFilter)Deprecated.Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters.voiddeleteCustomParameters(FilterConfiguration config)Deprecated.Deletes the parameters of a custom configuration.voidforEach(Consumer<? super FilterConfiguration> action)Deprecated.Iterator<FilterConfiguration>getAllConfigurations()Deprecated.Gets an iterator on all configurations objects for this mapper.FilterConfigurationgetConfiguration(String configId)Deprecated.Gets the FilterConfiguration object for a given configuration identifier.StringgetCustomConfigurationsDirectory()Deprecated.Gets the directory where the custom configuration files are stored.IParametersgetCustomParameters(FilterConfiguration config)Deprecated.Gets the parameters for a given custom filter configuration.IParametersgetCustomParameters(FilterConfiguration config, IFilter existingFilter)Deprecated.Gets the parameters for a given custom filter configuration.FilterConfigurationgetDefaultConfiguration(String mimeType)Deprecated.Gets the first filter configuration for a given MIME type.FilterConfigurationgetDefaultConfigurationFromExtension(String ext)Deprecated.Gets the first filter configuration for a given extension.List<FilterConfiguration>getFilterConfigurations(String filterClass)Deprecated.Gets a list of all FilterConfiguration objects for a given filter class.List<FilterInfo>getFiltersInfo()Deprecated.Gets a list of information on all filters in this mapper.List<FilterConfiguration>getMimeConfigurations(String mimeType)Deprecated.Gets a list of all FilterConfiguration objects for a given MIME type.IParametersgetParameters(FilterConfiguration config)Deprecated.Gets the parameters for a given configuration (predefined or custom).IParametersgetParameters(FilterConfiguration config, IFilter existingFilter)Deprecated.Gets the parameters for a given configuration (predefined or custom).protected IFilterinstantiateFilter(FilterConfiguration config, IFilter existingFilter)Deprecated.Instantiate a filter from a given configuration, trying to re-use an existing one.Iterator<FilterConfiguration>iterator()Deprecated.voidremoveConfiguration(String configId)Deprecated.Removes a given configuration from this mapper.voidremoveConfigurations(String filterClass)Deprecated.Removes all the configurations (predefined and custom) of a given filter from this mapper.voidsaveCustomParameters(FilterConfiguration config, IParameters params)Deprecated.Saves the parameters of a custom configuration.voidsetCustomConfigurationsDirectory(String dir)Deprecated.Sets the directory where the custom configuration files are stored.Spliterator<FilterConfiguration>spliterator()Deprecated.voidupdateCustomConfigurations()Deprecated.Updates the custom configurations for this mapper.-
Methods inherited from class net.sf.okapi.common.ParametersEditorMapper
addDescriptionProvider, addDescriptionProvider, addEditor, addEditor, clearDescriptionProviders, clearEditors, createParametersEditor, getDescriptionProvider, removeDescriptionProvider, removeEditor
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.okapi.common.filters.IFilterConfigurationMapper
addCustomConfiguration
-
-
-
-
Method Detail
-
addFromPlugins
public void addFromPlugins(PluginsManager pm)
Deprecated.
-
addConfigurations
public void addConfigurations(String filterClass)
Deprecated.Description copied from interface:IFilterConfigurationMapperAdds all the predefined configurations of a given filter to this mapper.- Specified by:
addConfigurationsin interfaceIFilterConfigurationMapper- Parameters:
filterClass- the class name of the filter to lookup.
-
addConfiguration
public void addConfiguration(FilterConfiguration config)
Deprecated.Description copied from interface:IFilterConfigurationMapperAdds a new configuration to this mapper.- Specified by:
addConfigurationin interfaceIFilterConfigurationMapper- Parameters:
config- the configuration to add.
-
createFilter
public IFilter createFilter(String configId)
Deprecated.Description copied from interface:IFilterConfigurationMapperCreates an instance of the filter for a given configuration identifier and loads its corresponding parameters.- Specified by:
createFilterin interfaceIFilterConfigurationMapper- Parameters:
configId- the configuration identifier to use for look-up.- Returns:
- a new
IFilterobject (with its parameters loaded) for the given configuration identifier, or null if the object could not be created.
-
createFilter
public IFilter createFilter(String configId, IFilter existingFilter)
Deprecated.Description copied from interface:IFilterConfigurationMapperCreates an instance of the filter for a given configuration identifier and loads its corresponding parameters.- Specified by:
createFilterin interfaceIFilterConfigurationMapper- Parameters:
configId- the configuration identifier to use for look-up.existingFilter- an optional existing instance of a filter. This argument can be null. If this argument is not null, it is checked against the requested filter and re-use if the requested filter and the provided instance are the same. If the provided instance is re-used, its parameters are always re-loaded. Providing an existing instance of the requested filter may allow for better efficiency.- Returns:
- a new
IFilterobject (with its parameters loaded) for the given configuration identifier, or null if the object could not be created.
-
getParameters
public IParameters getParameters(FilterConfiguration config)
Deprecated.Description copied from interface:IFilterConfigurationMapperGets the parameters for a given configuration (predefined or custom).- Specified by:
getParametersin interfaceIFilterConfigurationMapper- Parameters:
config- the configuration for which the parameters are requested.- Returns:
- the parameters object for the given configuration.
- See Also:
IFilterConfigurationMapper.getCustomParameters(FilterConfiguration)
-
getParameters
public IParameters getParameters(FilterConfiguration config, IFilter existingFilter)
Deprecated.Description copied from interface:IFilterConfigurationMapperGets the parameters for a given configuration (predefined or custom).- Specified by:
getParametersin interfaceIFilterConfigurationMapper- Parameters:
config- the configuration for which the parameters are requested.existingFilter- optional existing instance of the filter for the given configuration. This argument can be null. If it not null, the provided filter may be used to load the parameters (if it matches the appropriate class). Providing this argument may allow the method to be more efficient by not creating a temporary filter to get an instance of the parameters to load.- Returns:
- the parameters object for the given configuration.
-
createConfigurationEditor
public IParametersEditor createConfigurationEditor(String configId)
Deprecated.Description copied from interface:IFilterConfigurationMapperCreates an instance of the filter's parameters editor for a given configuration identifier.- Specified by:
createConfigurationEditorin interfaceIFilterConfigurationMapper- Parameters:
configId- the configuration identifier to use for look-up.- Returns:
- a new IParametersEditor object for the given configuration identifier, or null if no editor is available or if the object could not be created.
-
createConfigurationEditor
public IParametersEditor createConfigurationEditor(String configId, IFilter existingFilter)
Deprecated.Description copied from interface:IFilterConfigurationMapperCreates an instance of the filter's parameters editor for a given configuration identifier.- Specified by:
createConfigurationEditorin interfaceIFilterConfigurationMapper- Parameters:
configId- the configuration identifier to use for look-up.existingFilter- an optional existing instance of a filter. This argument can be null. If this argument is not null and matches the filter of the given configuration it is used instead of a temporay instance, to get an instance of the parameters object for which the editor is requested.- Returns:
- a new IParametersEditor object for the given configuration identifier, or null if no editor is available or if the object could not be created.
-
getConfiguration
public FilterConfiguration getConfiguration(String configId)
Deprecated.Description copied from interface:IFilterConfigurationMapperGets the FilterConfiguration object for a given configuration identifier.- Specified by:
getConfigurationin interfaceIFilterConfigurationMapper- Parameters:
configId- the configuration identifier to search for.- Returns:
- the FilterConfiguration object for the given configuration identifier, or null if a match could not be found.
-
getAllConfigurations
public Iterator<FilterConfiguration> getAllConfigurations()
Deprecated.Description copied from interface:IFilterConfigurationMapperGets an iterator on all configurations objects for this mapper.- Specified by:
getAllConfigurationsin interfaceIFilterConfigurationMapper- Returns:
- an iterator on all configurations for this mapper.
-
getMimeConfigurations
public List<FilterConfiguration> getMimeConfigurations(String mimeType)
Deprecated.Description copied from interface:IFilterConfigurationMapperGets a list of all FilterConfiguration objects for a given MIME type.- Specified by:
getMimeConfigurationsin interfaceIFilterConfigurationMapper- Parameters:
mimeType- mimeType MIME type to search for.- Returns:
- a list of all FilterConfiguration objects found for the given MIME type (the list may be empty).
-
getFilterConfigurations
public List<FilterConfiguration> getFilterConfigurations(String filterClass)
Deprecated.Description copied from interface:IFilterConfigurationMapperGets a list of all FilterConfiguration objects for a given filter class.- Specified by:
getFilterConfigurationsin interfaceIFilterConfigurationMapper- Parameters:
filterClass- the class name of the filter to search for.- Returns:
- a list of all FilterConfiguration objects found for the given filter class name (the list may be empty).
-
getDefaultConfiguration
public FilterConfiguration getDefaultConfiguration(String mimeType)
Deprecated.Description copied from interface:IFilterConfigurationMapperGets the first filter configuration for a given MIME type.- Specified by:
getDefaultConfigurationin interfaceIFilterConfigurationMapper- Parameters:
mimeType- MIME type to search for.- Returns:
- the filter configuration for the given MIME type, or null if none is found.
-
getDefaultConfigurationFromExtension
public FilterConfiguration getDefaultConfigurationFromExtension(String ext)
Deprecated.Description copied from interface:IFilterConfigurationMapperGets the first filter configuration for a given extension.- Specified by:
getDefaultConfigurationFromExtensionin interfaceIFilterConfigurationMapper- Parameters:
ext- the extension to search for (must be in the form ".ext" but can be in any case).- Returns:
- the filter configuration for the given extension, or null if none is found.
-
removeConfiguration
public void removeConfiguration(String configId)
Deprecated.Description copied from interface:IFilterConfigurationMapperRemoves a given configuration from this mapper.- Specified by:
removeConfigurationin interfaceIFilterConfigurationMapper- Parameters:
configId- the identifier of the configuration to remove.
-
removeConfigurations
public void removeConfigurations(String filterClass)
Deprecated.Description copied from interface:IFilterConfigurationMapperRemoves all the configurations (predefined and custom) of a given filter from this mapper.- Specified by:
removeConfigurationsin interfaceIFilterConfigurationMapper- Parameters:
filterClass- the class name of the filter to lookup.
-
getCustomParameters
public IParameters getCustomParameters(FilterConfiguration config)
Deprecated.Description copied from interface:IFilterConfigurationMapperGets the parameters for a given custom filter configuration. This method provides a way for this mapper to implements how it retrieves custom filter parameters.- Specified by:
getCustomParametersin interfaceIFilterConfigurationMapper- Parameters:
config- the custom configuration for which the method should return the filter parameters.- Returns:
- the parameters for the given custom filter configuration, or null if the parameters could not be provided, or if the corresponding filter does not have parameters.
- See Also:
IFilterConfigurationMapper.getParameters(FilterConfiguration)
-
getCustomParameters
public IParameters getCustomParameters(FilterConfiguration config, IFilter existingFilter)
Deprecated.Gets the parameters for a given custom filter configuration. This default implementation gets the custom data from a file located in the current directory at the time the method is called.- Specified by:
getCustomParametersin interfaceIFilterConfigurationMapper- Parameters:
config- the custom configuration for which the method should return the filter parameters.existingFilter- optional existing instance of the filter for the given configuration. This argument can be null. If it not null, the provided filter may be used to load the parameters (if it matches the appropriate class). Providing this argument may allow the method to be more efficient by not creating a temporary filter to get an instance of the parameters to load.- Returns:
- the parameters for the given custom filter configuration, or null if the parameters could not be provided, or if the corresponding filter does not have parameters.
-
deleteCustomParameters
public void deleteCustomParameters(FilterConfiguration config)
Deprecated.Description copied from interface:IFilterConfigurationMapperDeletes the parameters of a custom configuration. This method provides a way for this mapper to implements how it permanently delete custom filter parameters. The actual configuration is not removed from this mapper, you must do it by callingIFilterConfigurationMapper.removeConfiguration(String).- Specified by:
deleteCustomParametersin interfaceIFilterConfigurationMapper- Parameters:
config- the custom configuration for which to delete the parameters.
-
saveCustomParameters
public void saveCustomParameters(FilterConfiguration config, IParameters params)
Deprecated.Description copied from interface:IFilterConfigurationMapperSaves the parameters of a custom configuration. This method provides a way for this mapper to implements how it stores custom filter parameters.- Specified by:
saveCustomParametersin interfaceIFilterConfigurationMapper- Parameters:
config- the custom configuration for which to save the parameters.params- the parameters to save.
-
createCustomConfiguration
public FilterConfiguration createCustomConfiguration(FilterConfiguration baseConfig)
Deprecated.Description copied from interface:IFilterConfigurationMapperCreates a custom configuration object based on a give one. The new configuration is not added to the current list.- Specified by:
createCustomConfigurationin interfaceIFilterConfigurationMapper- Parameters:
baseConfig- the base configuration from which to base the new one.- Returns:
- a new
FilterConfigurationobject set with some default values, or null if the configuration could not be created.
-
clearConfigurations
public void clearConfigurations(boolean customOnly)
Deprecated.Description copied from interface:IFilterConfigurationMapperRemoves configuration mappings from this mapper.- Specified by:
clearConfigurationsin interfaceIFilterConfigurationMapper- Parameters:
customOnly- true to clear only the custom configurations, false to clear all the configurations from this mapper.
-
getCustomConfigurationsDirectory
public String getCustomConfigurationsDirectory()
Deprecated.Gets the directory where the custom configuration files are stored.- Returns:
- the directory where the custom configuration files are stored.
-
setCustomConfigurationsDirectory
public void setCustomConfigurationsDirectory(String dir)
Deprecated.Sets the directory where the custom configuration files are stored. You should callupdateCustomConfigurations()after this to update the list of the custom configurations in this mapper.- Parameters:
dir- the new directory where the custom configuration files are stored.
-
addCustomConfiguration
public void addCustomConfiguration(String configId, IParameters parameters)
Deprecated.Description copied from interface:IFilterConfigurationMapperAdd a customFilterConfigurationwithIParameters- Specified by:
addCustomConfigurationin interfaceIFilterConfigurationMapper- Parameters:
configId- the custom filter config id.parameters-IParametersfor the filter.
-
addCustomConfiguration
public void addCustomConfiguration(String configId, String parameters)
Deprecated.Description copied from interface:IFilterConfigurationMapperAdd a customFilterConfigurationwithIParameters- Specified by:
addCustomConfigurationin interfaceIFilterConfigurationMapper- Parameters:
configId- the custom filter config id.parameters- parameters as a string for the filter.
-
updateCustomConfigurations
public void updateCustomConfigurations()
Deprecated.Updates the custom configurations for this mapper. This should be called if the custom configurations directory has changed.
-
instantiateFilter
protected IFilter instantiateFilter(FilterConfiguration config, IFilter existingFilter)
Deprecated.Instantiate a filter from a given configuration, trying to re-use an existing one.- Parameters:
config- the configuration corresponding to the filter to load.existingFilter- an optional existing filter we can try to reuse.- Returns:
- the instance of the requested filter, or null if an error occurred.
- Throws:
OkapiFilterCreationException- if the filter could not be instantiated.
-
getFiltersInfo
public List<FilterInfo> getFiltersInfo()
Deprecated.Description copied from interface:IFilterConfigurationMapperGets a list of information on all filters in this mapper.- Specified by:
getFiltersInfoin interfaceIFilterConfigurationMapper- Returns:
- a list of information on all filters in this mapper.
-
iterator
public Iterator<FilterConfiguration> iterator()
Deprecated.- Specified by:
iteratorin interfaceIterable<FilterConfiguration>
-
forEach
public void forEach(Consumer<? super FilterConfiguration> action)
Deprecated.- Specified by:
forEachin interfaceIterable<FilterConfiguration>
-
spliterator
public Spliterator<FilterConfiguration> spliterator()
Deprecated.- Specified by:
spliteratorin interfaceIterable<FilterConfiguration>
-
-