Klasse DefaultValidator<T>
java.lang.Object
org.apache.fulcrum.intake.validator.DefaultValidator<T>
- Alle implementierten Schnittstellen:
org.apache.avalon.framework.logger.LogEnabled
,InitableByConstraintMap
,Validator<T>
- Bekannte direkte Unterklassen:
BooleanValidator
,DateStringValidator
,FileValidator
,NumberValidator
,StringValidator
public abstract class DefaultValidator<T>
extends Object
implements Validator<T>, InitableByConstraintMap, org.apache.avalon.framework.logger.LogEnabled
DefaultValidator that will compare a testValue against the following
constraints:
This validator can serve as the base class for more specific validators
Name | Valid Values | Default Value |
---|---|---|
required | true|false | false |
mask | regexp | |
minLength | integer | 0 |
maxLength | integer |
- Version:
- $Id$
- Autor:
- John McNally, Quinton McCombs, Colin Chalmers, Thomas Vandahl
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungprotected String
Error message pertaining to Rule that was brokenprotected org.apache.avalon.framework.logger.Logger
Loggingprotected int
The maximum length of the fieldprotected String
The message to show if field fails max-length testprotected int
The minimum length of the fieldprotected String
The message to show if field fails min-length testprotected boolean
A boolean value to signify if the field is definitely required or notprotected String
The message to show if field fails required testVon Schnittstelle geerbte Felder org.apache.fulcrum.intake.validator.Validator
FLEXIBLE_RULE_NAME, FORMAT_RULE_NAME, INVALID_NUMBER_RULE_NAME, MASK_RULE_NAME, MAX_LENGTH_RULE_NAME, MAX_VALUE_RULE_NAME, MIN_LENGTH_RULE_NAME, MIN_VALUE_RULE_NAME, REQUIRED_RULE_NAME
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
assertValidity
(String testValue) Determine whether a testValue meets the criteria specified in the constraints defined for this validatorvoid
assertValidity
(Field<T> field) Determine whether a field meets the criteria specified in the constraints defined for this validatorvoid
enableLogging
(org.apache.avalon.framework.logger.Logger logger) Enable Avalon Loggingint
Get the value of maxLength.Get the value of maxLengthMessage.Get the error message resulting from invalid input.int
Get the value of minLength.Get the value of minLengthMessage.Get the value of requiredMessage.void
init
(Map<String, ? extends Constraint> paramMap) Extract the relevant parameters from the constraints listed in <rule> tags within the intake.xml file.boolean
Get the value of required.boolean
Veraltet.use isValid(Field) insteadboolean
Determine whether a field meets the criteria specified in the constraints defined for this validatorvoid
setMaxLength
(int maxLength) Set the value of maxLength.void
setMaxLengthMessage
(String maxLengthMessage) Set the value of maxLengthMessage.void
setMinLength
(int minLength) Set the value of minLength.void
setMinLengthMessage
(String minLengthMessage) Set the value of minLengthMessage.void
setRequired
(boolean required) Set the value of required.void
setRequiredMessage
(String requiredMessage) Set the value of requiredMessage.
-
Felddetails
-
required
protected boolean requiredA boolean value to signify if the field is definitely required or not -
requiredMessage
The message to show if field fails required test -
minLength
protected int minLengthThe minimum length of the field -
minLengthMessage
The message to show if field fails min-length test -
maxLength
protected int maxLengthThe maximum length of the field -
maxLengthMessage
The message to show if field fails max-length test -
errorMessage
Error message pertaining to Rule that was broken -
log
protected org.apache.avalon.framework.logger.Logger logLogging
-
-
Konstruktordetails
-
DefaultValidator
public DefaultValidator()Default constructor
-
-
Methodendetails
-
enableLogging
public void enableLogging(org.apache.avalon.framework.logger.Logger logger) Enable Avalon Logging- Angegeben von:
enableLogging
in Schnittstelleorg.apache.avalon.framework.logger.LogEnabled
-
init
Extract the relevant parameters from the constraints listed in <rule> tags within the intake.xml file.- Angegeben von:
init
in SchnittstelleInitableByConstraintMap
- Parameter:
paramMap
- aMap
ofRule
's containing constraints on the input.- Löst aus:
InvalidMaskException
- An invalid mask was specified for one of the rules
-
isValid
Determine whether a field meets the criteria specified in the constraints defined for this validator -
assertValidity
Determine whether a field meets the criteria specified in the constraints defined for this validator- Angegeben von:
assertValidity
in SchnittstelleValidator<T>
- Parameter:
field
- aField
to be tested- Löst aus:
ValidationException
- containing an error message if the testValue did not pass the validation tests.
-
isValid
Veraltet.use isValid(Field) insteadDetermine whether a testValue meets the criteria specified in the constraints defined for this validator -
assertValidity
Determine whether a testValue meets the criteria specified in the constraints defined for this validator- Angegeben von:
assertValidity
in SchnittstelleValidator<T>
- Parameter:
testValue
- aString
to be tested- Löst aus:
ValidationException
- containing an error message if the testValue did not pass the validation tests.
-
getMessage
Get the error message resulting from invalid input.- Angegeben von:
getMessage
in SchnittstelleValidator<T>
- Gibt zurück:
- a
String
message, or the empty String "".
-
isRequired
public boolean isRequired()Get the value of required.- Gibt zurück:
- value of required.
-
setRequired
public void setRequired(boolean required) Set the value of required.- Parameter:
required
- Value to assign to required.
-
getRequiredMessage
Get the value of requiredMessage.- Gibt zurück:
- value of requiredMessage.
-
setRequiredMessage
Set the value of requiredMessage.- Parameter:
requiredMessage
- Value to assign to requiredMessage.
-
getMinLength
public int getMinLength()Get the value of minLength.- Gibt zurück:
- value of minLength.
-
setMinLength
public void setMinLength(int minLength) Set the value of minLength.- Parameter:
minLength
- Value to assign to minLength.
-
getMinLengthMessage
Get the value of minLengthMessage.- Gibt zurück:
- value of minLengthMessage.
-
setMinLengthMessage
Set the value of minLengthMessage.- Parameter:
minLengthMessage
- Value to assign to minLengthMessage.
-
getMaxLength
public int getMaxLength()Get the value of maxLength.- Gibt zurück:
- value of maxLength.
-
setMaxLength
public void setMaxLength(int maxLength) Set the value of maxLength.- Parameter:
maxLength
- Value to assign to maxLength.
-
getMaxLengthMessage
Get the value of maxLengthMessage.- Gibt zurück:
- value of maxLengthMessage.
-
setMaxLengthMessage
Set the value of maxLengthMessage.- Parameter:
maxLengthMessage
- Value to assign to maxLengthMessage.
-