public class FilterConfigurationMapper extends ParametersEditorMapper implements IFilterConfigurationMapper
IFilterConfigurationMapper interface.
In this implementation the custom configurations are stored as simple files in the file system
of the machine and the value for FilterConfiguration.parametersLocation for a custom
configuration is filename of the parameters file. The directory where the files are
located is defined with the setCustomConfigurationsDirectory(String).| Modifier and Type | Field and 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.
|
descMap, editorMap| Constructor and Description |
|---|
FilterConfigurationMapper()
Creates a new FilterConfigurationMapper object with no mappings and the
custom configuration directory set to the current directory.
|
| Modifier and Type | Method and 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.
|
void |
addCustomConfiguration(String configId) |
void |
addCustomConfiguration(String configId,
IParameters parameters) |
void |
addFromPlugins(PluginsManager pm) |
void |
clearConfigurations(boolean customOnly)
Removes configuration mappings from this mapper.
|
IParametersEditor |
createConfigurationEditor(String configId)
Creates an instance of the filter's parameters editor for a given
configuration identifier.
|
IParametersEditor |
createConfigurationEditor(String configId,
IFilter existingFilter)
Creates an instance of the filter's parameters editor for a given
configuration identifier.
|
FilterConfiguration |
createCustomConfiguration(FilterConfiguration baseConfig)
Creates a custom configuration object based on a give one.
|
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)
Deletes the parameters of a custom configuration.
|
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.
|
String |
getCustomConfigurationsDirectory()
Gets the directory where the custom configuration files are stored.
|
IParameters |
getCustomParameters(FilterConfiguration config)
Gets the parameters for a given custom filter configuration.
|
IParameters |
getCustomParameters(FilterConfiguration config,
IFilter existingFilter)
Gets the parameters for a given custom filter configuration.
|
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()
Gets a list of information on all filters in this mapper.
|
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).
|
protected IFilter |
instantiateFilter(FilterConfiguration config,
IFilter existingFilter)
Instantiate a filter from a given configuration, trying to re-use an existing one.
|
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)
Saves the parameters of a custom configuration.
|
void |
setCustomConfigurationsDirectory(String dir)
Sets the directory where the custom configuration files are stored.
|
static String[] |
splitFilterFromConfiguration(String configId)
Splits a configuration identifier into a filter identifier and the parameters info.
|
void |
updateCustomConfigurations()
Updates the custom configurations for this mapper.
|
addDescriptionProvider, addDescriptionProvider, addEditor, addEditor, clearDescriptionProviders, clearEditors, createParametersEditor, getDescriptionProvider, removeDescriptionProvider, removeEditorclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddEditor, clearEditors, removeEditoraddDescriptionProvider, addDescriptionProvider, addEditor, clearDescriptionProviders, createParametersEditor, getDescriptionProvider, removeDescriptionProviderpublic static final String CONFIGFILE_EXT
public static final char CONFIGFILE_SEPARATOR
public FilterConfigurationMapper()
public static String[] splitFilterFromConfiguration(String configId)
configId - the configuration identifier to split.public void addFromPlugins(PluginsManager pm)
public void addConfigurations(String filterClass)
IFilterConfigurationMapperaddConfigurations in interface IFilterConfigurationMapperfilterClass - the class name of the filter to lookup.public void addConfiguration(FilterConfiguration config)
IFilterConfigurationMapperaddConfiguration in interface IFilterConfigurationMapperconfig - the configuration to add.public IFilter createFilter(String configId)
IFilterConfigurationMappercreateFilter in interface IFilterConfigurationMapperconfigId - the configuration identifier to use for look-up.IFilter object (with its parameters loaded) for the given
configuration identifier, or null if the object could not be created.public IFilter createFilter(String configId, IFilter existingFilter)
IFilterConfigurationMappercreateFilter in interface IFilterConfigurationMapperconfigId - 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.IFilter object (with its parameters loaded) for the given
configuration identifier, or null if the object could not be created.public IParameters getParameters(FilterConfiguration config)
IFilterConfigurationMappergetParameters in interface IFilterConfigurationMapperconfig - the configuration for which the parameters are requested.IFilterConfigurationMapper.getCustomParameters(FilterConfiguration)public IParameters getParameters(FilterConfiguration config, IFilter existingFilter)
IFilterConfigurationMappergetParameters in interface IFilterConfigurationMapperconfig - 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.public IParametersEditor createConfigurationEditor(String configId)
IFilterConfigurationMappercreateConfigurationEditor in interface IFilterConfigurationMapperconfigId - the configuration identifier to use for look-up.public IParametersEditor createConfigurationEditor(String configId, IFilter existingFilter)
IFilterConfigurationMappercreateConfigurationEditor in interface IFilterConfigurationMapperconfigId - 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.public FilterConfiguration getConfiguration(String configId)
IFilterConfigurationMappergetConfiguration in interface IFilterConfigurationMapperconfigId - the configuration identifier to search for.public Iterator<FilterConfiguration> getAllConfigurations()
IFilterConfigurationMappergetAllConfigurations in interface IFilterConfigurationMapperpublic List<FilterConfiguration> getMimeConfigurations(String mimeType)
IFilterConfigurationMappergetMimeConfigurations in interface IFilterConfigurationMappermimeType - mimeType MIME type to search for.public List<FilterConfiguration> getFilterConfigurations(String filterClass)
IFilterConfigurationMappergetFilterConfigurations in interface IFilterConfigurationMapperfilterClass - the class name of the filter to search for.public FilterConfiguration getDefaultConfiguration(String mimeType)
IFilterConfigurationMappergetDefaultConfiguration in interface IFilterConfigurationMappermimeType - MIME type to search for.public FilterConfiguration getDefaultConfigurationFromExtension(String ext)
IFilterConfigurationMappergetDefaultConfigurationFromExtension in interface IFilterConfigurationMapperext - the extension to search for (must be in the form ".ext"
but can be in any case).public void removeConfiguration(String configId)
IFilterConfigurationMapperremoveConfiguration in interface IFilterConfigurationMapperconfigId - the identifier of the configuration to remove.public void removeConfigurations(String filterClass)
IFilterConfigurationMapperremoveConfigurations in interface IFilterConfigurationMapperfilterClass - the class name of the filter to lookup.public IParameters getCustomParameters(FilterConfiguration config)
IFilterConfigurationMappergetCustomParameters in interface IFilterConfigurationMapperconfig - the custom configuration for which the method should return the
filter parameters.IFilterConfigurationMapper.getParameters(FilterConfiguration)public IParameters getCustomParameters(FilterConfiguration config, IFilter existingFilter)
getCustomParameters in interface IFilterConfigurationMapperconfig - 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.public void deleteCustomParameters(FilterConfiguration config)
IFilterConfigurationMapperIFilterConfigurationMapper.removeConfiguration(String).deleteCustomParameters in interface IFilterConfigurationMapperconfig - the custom configuration for which to delete the parameters.public void saveCustomParameters(FilterConfiguration config, IParameters params)
IFilterConfigurationMappersaveCustomParameters in interface IFilterConfigurationMapperconfig - the custom configuration for which to save the parameters.params - the parameters to save.public FilterConfiguration createCustomConfiguration(FilterConfiguration baseConfig)
IFilterConfigurationMappercreateCustomConfiguration in interface IFilterConfigurationMapperbaseConfig - the base configuration from which to base the new one.FilterConfiguration object set with some
default values, or null if the configuration could not be created.public void clearConfigurations(boolean customOnly)
IFilterConfigurationMapperclearConfigurations in interface IFilterConfigurationMappercustomOnly - true to clear only the custom configurations, false to
clear all the configurations from this mapper.public String getCustomConfigurationsDirectory()
public void setCustomConfigurationsDirectory(String dir)
updateCustomConfigurations() after this to
update the list of the custom configurations in this mapper.dir - the new directory where the custom configuration files are stored.public void addCustomConfiguration(String configId, IParameters parameters)
public void addCustomConfiguration(String configId)
public void updateCustomConfigurations()
protected IFilter instantiateFilter(FilterConfiguration config, IFilter existingFilter)
config - the configuration corresponding to the filter to load.existingFilter - an optional existing filter we can try to reuse.OkapiFilterCreationException - if the filter could not be instantiated.public List<FilterInfo> getFiltersInfo()
IFilterConfigurationMappergetFiltersInfo in interface IFilterConfigurationMapperCopyright © 2022. All rights reserved.