Package net.sf.okapi.common.filters
Interface IFilterConfigurationMapper
-
- All Superinterfaces:
Iterable<FilterConfiguration>
- All Known Implementing Classes:
FilterConfigurationMapper
,ThreadSafeFilterConfigurationMapper
public interface IFilterConfigurationMapper extends Iterable<FilterConfiguration>
Common set of methods to manage filter configurations.This interface allows you to add and remove filter configurations from a central place. You can instantiate the filter corresponding to a given configuration, as well as manipulate its parameters.
Classes that implements this interface should consider overriding the methods related to custom configurations to provide application-specific storage mechanism and naming convention. The methods related to custom configurations are, for example:
createCustomConfiguration(FilterConfiguration)
,deleteCustomParameters(FilterConfiguration)
,getCustomParameters(FilterConfiguration)
,getCustomParameters(FilterConfiguration, IFilter)
, andsaveCustomParameters(FilterConfiguration, IParameters)
.
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONFIGFILE_EXT
Extension of the custom configuration files of this mapper.static char
CONFIGFILE_SEPARATOR
Character used to separate the filter name from the custom configuration name in a custom configuration identifier for this mapper.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description void
addConfiguration(FilterConfiguration config)
Adds a new configuration to this mapper.void
addConfigurations(String filterClass)
Adds all the predefined configurations of a given filter to this mapper.default void
addCustomConfiguration(String configId)
Add a customFilterConfiguration
void
addCustomConfiguration(String configId, String parameters)
Add a customFilterConfiguration
withIParameters
void
addCustomConfiguration(String configId, IParameters parameters)
Add a customFilterConfiguration
withIParameters
void
clearConfigurations(boolean customOnly)
Removes configuration mappings from this mapper.IParametersEditor
createConfigurationEditor(String configId)
Deprecated, for removal: This API element is subject to removal in a future version.This is UI specific and will be removed in the future.IParametersEditor
createConfigurationEditor(String configId, IFilter existingFilter)
Deprecated, for removal: This API element is subject to removal in a future version.This is UI specific and will be removed in the future.FilterConfiguration
createCustomConfiguration(FilterConfiguration baseConfig)
Deprecated, for removal: This API element is subject to removal in a future version.This is UI specific and will be removed in the future.IFilter
createFilter(String configId)
Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters.IFilter
createFilter(String configId, IFilter existingFilter)
Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters.void
deleteCustomParameters(FilterConfiguration config)
Deprecated, for removal: This API element is subject to removal in a future version.This is UI specific and will be removed in the future.Iterator<FilterConfiguration>
getAllConfigurations()
Gets an iterator on all configurations objects for this mapper.FilterConfiguration
getConfiguration(String configId)
Gets the FilterConfiguration object for a given configuration identifier.IParameters
getCustomParameters(FilterConfiguration config)
Deprecated, for removal: This API element is subject to removal in a future version.This is UI specific and will be removed in the future.IParameters
getCustomParameters(FilterConfiguration config, IFilter existingFilter)
Deprecated, for removal: This API element is subject to removal in a future version.This is UI specific and will be removed in the future.FilterConfiguration
getDefaultConfiguration(String mimeType)
Gets the first filter configuration for a given MIME type.FilterConfiguration
getDefaultConfigurationFromExtension(String ext)
Gets the first filter configuration for a given extension.List<FilterConfiguration>
getFilterConfigurations(String filterClass)
Gets a list of all FilterConfiguration objects for a given filter class.List<FilterInfo>
getFiltersInfo()
Deprecated, for removal: This API element is subject to removal in a future version.This is UI specific and will be removed in the future.List<FilterConfiguration>
getMimeConfigurations(String mimeType)
Gets a list of all FilterConfiguration objects for a given MIME type.IParameters
getParameters(FilterConfiguration config)
Gets the parameters for a given configuration (predefined or custom).IParameters
getParameters(FilterConfiguration config, IFilter existingFilter)
Gets the parameters for a given configuration (predefined or custom).void
removeConfiguration(String configId)
Removes a given configuration from this mapper.void
removeConfigurations(String filterClass)
Removes all the configurations (predefined and custom) of a given filter from this mapper.void
saveCustomParameters(FilterConfiguration config, IParameters params)
Deprecated, for removal: This API element is subject to removal in a future version.This is UI specific and will be removed in the future.static String[]
splitFilterFromConfiguration(String configId)
Splits a configuration identifier into a filter identifier and the parameters info.-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Field Detail
-
CONFIGFILE_EXT
static final String CONFIGFILE_EXT
Extension of the custom configuration files of this mapper.- See Also:
- Constant Field Values
-
CONFIGFILE_SEPARATOR
static final char CONFIGFILE_SEPARATOR
Character used to separate the filter name from the custom configuration name in a custom configuration identifier for this mapper.- See Also:
- Constant Field Values
-
-
Method Detail
-
splitFilterFromConfiguration
static String[] splitFilterFromConfiguration(String configId)
Splits a configuration identifier into a filter identifier and the parameters info.- Parameters:
configId
- the configuration identifier to split.- Returns:
- an array of two strings: 0=filter (e.g. "okf_xml", 1=parameter info (or null).
-
addConfiguration
void addConfiguration(FilterConfiguration config)
Adds a new configuration to this mapper.- Parameters:
config
- the configuration to add.
-
removeConfiguration
void removeConfiguration(String configId)
Removes a given configuration from this mapper.- Parameters:
configId
- the identifier of the configuration to remove.
-
addConfigurations
void addConfigurations(String filterClass)
Adds all the predefined configurations of a given filter to this mapper.- Parameters:
filterClass
- the class name of the filter to lookup.
-
removeConfigurations
void removeConfigurations(String filterClass)
Removes all the configurations (predefined and custom) of a given filter from this mapper.- Parameters:
filterClass
- the class name of the filter to lookup.
-
clearConfigurations
void clearConfigurations(boolean customOnly)
Removes configuration mappings from this mapper.- Parameters:
customOnly
- true to clear only the custom configurations, false to clear all the configurations from this mapper.
-
createFilter
IFilter createFilter(String configId, IFilter existingFilter)
Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters.- 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
IFilter
object (with its parameters loaded) for the given configuration identifier, or null if the object could not be created. - Throws:
OkapiFilterCreationException
- if the filter could not be created.
-
createFilter
IFilter createFilter(String configId)
Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters.- Parameters:
configId
- the configuration identifier to use for look-up.- Returns:
- a new
IFilter
object (with its parameters loaded) for the given configuration identifier, or null if the object could not be created. - Throws:
OkapiFilterCreationException
- if the filter could not be created.
-
createConfigurationEditor
@Deprecated(forRemoval=true) IParametersEditor createConfigurationEditor(String configId, IFilter existingFilter)
Deprecated, for removal: This API element is subject to removal in a future version.This is UI specific and will be removed in the future.Creates an instance of the filter's parameters editor for a given configuration identifier.- 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.
- Throws:
OkapiFilterCreationException
- if a filter needed to be created and could not.OkapiEditorCreationException
- if the editor could not be created.
-
createConfigurationEditor
@Deprecated(forRemoval=true) IParametersEditor createConfigurationEditor(String configId)
Deprecated, for removal: This API element is subject to removal in a future version.This is UI specific and will be removed in the future.Creates an instance of the filter's parameters editor for a given configuration identifier.- 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.
- Throws:
OkapiFilterCreationException
- if a filter needed to be created and could not.OkapiEditorCreationException
- if the editor could not be created.
-
getConfiguration
FilterConfiguration getConfiguration(String configId)
Gets the FilterConfiguration object for a given configuration identifier.- 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.
-
getDefaultConfiguration
FilterConfiguration getDefaultConfiguration(String mimeType)
Gets the first filter configuration for a given MIME type.- Parameters:
mimeType
- MIME type to search for.- Returns:
- the filter configuration for the given MIME type, or null if none is found.
-
getDefaultConfigurationFromExtension
FilterConfiguration getDefaultConfigurationFromExtension(String ext)
Gets the first filter configuration for a given extension.- 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.
-
getFiltersInfo
@Deprecated(forRemoval=true) List<FilterInfo> getFiltersInfo()
Deprecated, for removal: This API element is subject to removal in a future version.This is UI specific and will be removed in the future.Gets a list of information on all filters in this mapper.- Returns:
- a list of information on all filters in this mapper.
-
getAllConfigurations
Iterator<FilterConfiguration> getAllConfigurations()
Gets an iterator on all configurations objects for this mapper.- Returns:
- an iterator on all configurations for this mapper.
-
getMimeConfigurations
List<FilterConfiguration> getMimeConfigurations(String mimeType)
Gets a list of all FilterConfiguration objects for a given MIME type.- 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
List<FilterConfiguration> getFilterConfigurations(String filterClass)
Gets a list of all FilterConfiguration objects for a given filter class.- 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).
-
getParameters
IParameters getParameters(FilterConfiguration config)
Gets the parameters for a given configuration (predefined or custom).- Parameters:
config
- the configuration for which the parameters are requested.- Returns:
- the parameters object for the given configuration.
- See Also:
getCustomParameters(FilterConfiguration)
-
getParameters
IParameters getParameters(FilterConfiguration config, IFilter existingFilter)
Gets the parameters for a given configuration (predefined or custom).- 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.
-
createCustomConfiguration
@Deprecated(forRemoval=true) FilterConfiguration createCustomConfiguration(FilterConfiguration baseConfig)
Deprecated, for removal: This API element is subject to removal in a future version.This is UI specific and will be removed in the future.Creates a custom configuration object based on a give one. The new configuration is not added to the current list.- Parameters:
baseConfig
- the base configuration from which to base the new one.- Returns:
- a new
FilterConfiguration
object set with some default values, or null if the configuration could not be created.
-
getCustomParameters
@Deprecated(forRemoval=true) IParameters getCustomParameters(FilterConfiguration config, IFilter existingFilter)
Deprecated, for removal: This API element is subject to removal in a future version.This is UI specific and will be removed in the future.Gets the parameters for a given custom filter configuration. This method provides a way for this mapper to implements how it retrieves custom filter parameters.- 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.
- Throws:
OkapiFilterCreationException
- if the filter of the given configuration could not be created to load the parameters.
-
getCustomParameters
@Deprecated(forRemoval=true) IParameters getCustomParameters(FilterConfiguration config)
Deprecated, for removal: This API element is subject to removal in a future version.This is UI specific and will be removed in the future.Gets the parameters for a given custom filter configuration. This method provides a way for this mapper to implements how it retrieves custom filter parameters.- 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.
- Throws:
OkapiFilterCreationException
- if the filter of the given configuration could not be created to load the parameters.- See Also:
getParameters(FilterConfiguration)
-
saveCustomParameters
@Deprecated(forRemoval=true) void saveCustomParameters(FilterConfiguration config, IParameters params)
Deprecated, for removal: This API element is subject to removal in a future version.This is UI specific and will be removed in the future.Saves the parameters of a custom configuration. This method provides a way for this mapper to implements how it stores custom filter parameters.- Parameters:
config
- the custom configuration for which to save the parameters.params
- the parameters to save.
-
deleteCustomParameters
@Deprecated(forRemoval=true) void deleteCustomParameters(FilterConfiguration config)
Deprecated, for removal: This API element is subject to removal in a future version.This is UI specific and will be removed in the future.Deletes 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 callingremoveConfiguration(String)
.- Parameters:
config
- the custom configuration for which to delete the parameters.
-
addCustomConfiguration
void addCustomConfiguration(String configId, IParameters parameters)
Add a customFilterConfiguration
withIParameters
- Parameters:
configId
- the custom filter config id.parameters
-IParameters
for the filter.
-
addCustomConfiguration
void addCustomConfiguration(String configId, String parameters)
Add a customFilterConfiguration
withIParameters
- Parameters:
configId
- the custom filter config id.parameters
- parameters as a string for the filter.
-
addCustomConfiguration
default void addCustomConfiguration(String configId)
Add a customFilterConfiguration
- Parameters:
configId
- the custom filter config id.
-
-