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 StringError message pertaining to Rule that was brokenprotected org.apache.avalon.framework.logger.LoggerLoggingprotected intThe maximum length of the fieldprotected StringThe message to show if field fails max-length testprotected intThe minimum length of the fieldprotected StringThe message to show if field fails min-length testprotected booleanA boolean value to signify if the field is definitely required or notprotected StringThe 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 TypMethodeBeschreibungvoidassertValidity(String testValue) Determine whether a testValue meets the criteria specified in the constraints defined for this validatorvoidassertValidity(Field<T> field) Determine whether a field meets the criteria specified in the constraints defined for this validatorvoidenableLogging(org.apache.avalon.framework.logger.Logger logger) Enable Avalon LoggingintGet the value of maxLength.Get the value of maxLengthMessage.Get the error message resulting from invalid input.intGet the value of minLength.Get the value of minLengthMessage.Get the value of requiredMessage.voidinit(Map<String, ? extends Constraint> paramMap) Extract the relevant parameters from the constraints listed in <rule> tags within the intake.xml file.booleanGet the value of required.booleanVeraltet.use isValid(Field) insteadbooleanDetermine whether a field meets the criteria specified in the constraints defined for this validatorvoidsetMaxLength(int maxLength) Set the value of maxLength.voidsetMaxLengthMessage(String maxLengthMessage) Set the value of maxLengthMessage.voidsetMinLength(int minLength) Set the value of minLength.voidsetMinLengthMessage(String minLengthMessage) Set the value of minLengthMessage.voidsetRequired(boolean required) Set the value of required.voidsetRequiredMessage(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:
enableLoggingin 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:
initin SchnittstelleInitableByConstraintMap- Parameter:
paramMap- aMapofRule'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:
assertValidityin SchnittstelleValidator<T>- Parameter:
field- aFieldto 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:
assertValidityin SchnittstelleValidator<T>- Parameter:
testValue- aStringto 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:
getMessagein SchnittstelleValidator<T>- Gibt zurück:
- a
Stringmessage, 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.
-