public class DefaultValidator extends AbstractLogEnabled implements Validator, Configurable, PluginAware, Serviceable
Modifier and Type | Field and Description |
---|---|
protected I18nizableText |
_invalidText
The error text to display if regexp fails
|
protected boolean |
_isMandatory
Is the value mandatory ?
|
protected String |
_pluginName
The plugin name
|
protected Pattern |
_regexp
Does the value need to match a regexp
|
protected ServiceManager |
_smanager
The service manager
|
Constructor and Description |
---|
DefaultValidator()
Default constructor for avalon
|
DefaultValidator(String regexp,
boolean mandatory)
Manual constructor
|
DefaultValidator(String regexp,
I18nizableText invalidText,
boolean mandatory)
Manual constructor
|
Modifier and Type | Method and Description |
---|---|
private boolean |
_matchRegexp(Object[] values) |
void |
configure(Configuration configuration) |
Map<String,Object> |
getConfiguration()
Retrieves the configuration of the validator.
|
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.
|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
protected boolean _isMandatory
protected I18nizableText _invalidText
protected String _pluginName
protected ServiceManager _smanager
public DefaultValidator()
public DefaultValidator(String regexp, boolean mandatory)
regexp
- The regexp to check or nullmandatory
- Is the value mandatorypublic DefaultValidator(String regexp, I18nizableText invalidText, boolean mandatory)
regexp
- The regexp to check or nullinvalidText
- The error text to displaymandatory
- Is the value mandatorypublic void service(ServiceManager smanager) throws ServiceException
service
in interface Serviceable
ServiceException
public void setPluginInfo(String pluginName, String featureName, String id)
PluginAware
setPluginInfo
in interface PluginAware
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this componentpublic void configure(Configuration configuration) throws ConfigurationException
configure
in interface Configurable
ConfigurationException
public Map<String,Object> getConfiguration()
Validator
getConfiguration
in interface Validator
public void validate(Object value, Errors errors)
Validator
protected void validateSingleValue(Object value, Errors errors)
value
- the value to validate (can be null
).errors
- the structure to populate if the validation failed.protected void validateArrayValues(Object[] values, Errors errors)
values
- the values to validateerrors
- the structure to populate if the validation failed.private boolean _matchRegexp(Object[] values)