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
,ReferenceValidator
,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
_invalidText
The error text to display if regexp failsprotected boolean
_isMandatory
Is the value mandatory ?protected String
_pluginName
The plugin nameprotected Pattern
_regexp
Does the value need to match a regexpprotected ServiceManager
_smanager
The 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 void
configure(Configuration configuration)
boolean
equals(Object obj)
Map<String,Object>
getConfiguration()
Retrieves the configuration of the validator.int
hashCode()
void
service(ServiceManager smanager)
void
setPluginInfo(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.void
validate(Object value, Errors errors)
Validates a value.protected void
validateArrayValues(Object[] values, Errors errors)
Validates a array of values.protected void
validateSingleValue(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:
service
in interfaceServiceable
- Throws:
ServiceException
-
setPluginInfo
public void setPluginInfo(String pluginName, String featureName, String id)
Description copied from interface:PluginAware
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.- Specified by:
setPluginInfo
in 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:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
getConfiguration
public Map<String,Object> getConfiguration()
Description copied from interface:Validator
Retrieves the configuration of the validator.- Specified by:
getConfiguration
in interfaceValidator
- Returns:
- a map containing the configuration information.
-
validate
public void validate(Object value, Errors errors)
Description copied from interface:Validator
Validates 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.
-
-