Package org.ametys.runtime.parameter
Class DefaultValidator
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.runtime.parameter.DefaultValidator
-
- All Implemented Interfaces:
Validator,PluginAware,Configurable,LogEnabled,Serviceable
- Direct Known Subclasses:
CandidatesValidator,RegexpValidator,SQLDatabaseTypeValidator,TextValidator
public class DefaultValidator extends AbstractLogEnabled implements Validator, Configurable, PluginAware, Serviceable
This default implementation validates the following configurable stuff:- mandatory: check the parameter is set
- regexp: check the string parameter matches a regexp
-
-
Field Summary
Fields Modifier and Type Field Description protected I18nizableText_invalidTextThe error text to display if regexp failsprotected boolean_isMandatoryIs the value mandatory ?protected String_pluginNameThe plugin nameprotected Pattern_regexpDoes the value need to match a regexpprotected ServiceManager_smanagerThe service manager
-
Constructor Summary
Constructors Constructor Description DefaultValidator()Default constructor for avalonDefaultValidator(String regexp, boolean mandatory)Manual constructorDefaultValidator(String regexp, I18nizableText invalidText, boolean mandatory)Manual constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean_matchRegexp(Object[] values)voidconfigure(Configuration configuration)Map<String,Object>getConfiguration()Retrieves the configuration of the validator.voidservice(ServiceManager smanager)voidsetPluginInfo(String pluginName, String featureName, String id)Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.voidvalidate(Object value, Errors errors)Validates a value.protected voidvalidateArrayValues(Object[] values, Errors errors)Validates a array of values.protected voidvalidateSingleValue(Object value, Errors errors)Validates a single value.-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
_isMandatory
protected boolean _isMandatory
Is the value mandatory ?
-
_invalidText
protected I18nizableText _invalidText
The error text to display if regexp fails
-
_pluginName
protected String _pluginName
The plugin name
-
_smanager
protected ServiceManager _smanager
The service manager
-
-
Constructor Detail
-
DefaultValidator
public DefaultValidator()
Default constructor for avalon
-
DefaultValidator
public DefaultValidator(String regexp, boolean mandatory)
Manual constructor- Parameters:
regexp- The regexp to check or nullmandatory- Is the value mandatory
-
DefaultValidator
public DefaultValidator(String regexp, I18nizableText invalidText, boolean mandatory)
Manual constructor- Parameters:
regexp- The regexp to check or nullinvalidText- The error text to displaymandatory- Is the value mandatory
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
setPluginInfo
public void setPluginInfo(String pluginName, String featureName, String id)
Description copied from interface:PluginAwareSets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfoin interfacePluginAware- Parameters:
pluginName- Unique identifier for the plugin hosting the extensionfeatureName- Unique feature identifier (unique for a given pluginName)id- Unique identifier of this component
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configurein interfaceConfigurable- Throws:
ConfigurationException
-
getConfiguration
public Map<String,Object> getConfiguration()
Description copied from interface:ValidatorRetrieves the configuration of the validator.- Specified by:
getConfigurationin interfaceValidator- Returns:
- a map containing the configuration information.
-
validate
public void validate(Object value, Errors errors)
Description copied from interface:ValidatorValidates a value.
-
validateSingleValue
protected void validateSingleValue(Object value, Errors errors)
Validates a single value.- Parameters:
value- the value to validate (can benull).errors- the structure to populate if the validation failed.
-
validateArrayValues
protected void validateArrayValues(Object[] values, Errors errors)
Validates a array of values.- Parameters:
values- the values to validateerrors- the structure to populate if the validation failed.
-
_matchRegexp
private boolean _matchRegexp(Object[] values)
-
-