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:
Validation rules
NameValid ValuesDefault Value
requiredtrue|falsefalse
maskregexp 
minLengthinteger0
maxLengthinteger 
This validator can serve as the base class for more specific validators
Version:
$Id$
Autor:
John McNally, Quinton McCombs, Colin Chalmers, Thomas Vandahl
  • Felddetails

    • required

      protected boolean required
      A boolean value to signify if the field is definitely required or not
    • requiredMessage

      protected String requiredMessage
      The message to show if field fails required test
    • minLength

      protected int minLength
      The minimum length of the field
    • minLengthMessage

      protected String minLengthMessage
      The message to show if field fails min-length test
    • maxLength

      protected int maxLength
      The maximum length of the field
    • maxLengthMessage

      protected String maxLengthMessage
      The message to show if field fails max-length test
    • errorMessage

      protected String errorMessage
      Error message pertaining to Rule that was broken
    • log

      protected org.apache.avalon.framework.logger.Logger log
      Logging
  • 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 Schnittstelle org.apache.avalon.framework.logger.LogEnabled
    • init

      public void init(Map<String,? extends Constraint> paramMap) throws InvalidMaskException
      Extract the relevant parameters from the constraints listed in <rule> tags within the intake.xml file.
      Angegeben von:
      init in Schnittstelle InitableByConstraintMap
      Parameter:
      paramMap - a Map of Rule's containing constraints on the input.
      Löst aus:
      InvalidMaskException - An invalid mask was specified for one of the rules
    • isValid

      public boolean isValid(Field<T> field)
      Determine whether a field meets the criteria specified in the constraints defined for this validator
      Angegeben von:
      isValid in Schnittstelle Validator<T>
      Parameter:
      field - a Field to be tested
      Gibt zurück:
      true if valid, false otherwise
    • assertValidity

      public void assertValidity(Field<T> field) throws ValidationException
      Determine whether a field meets the criteria specified in the constraints defined for this validator
      Angegeben von:
      assertValidity in Schnittstelle Validator<T>
      Parameter:
      field - a Field to be tested
      Löst aus:
      ValidationException - containing an error message if the testValue did not pass the validation tests.
    • isValid

      @Deprecated public boolean isValid(String testValue)
      Veraltet.
      use isValid(Field) instead
      Determine whether a testValue meets the criteria specified in the constraints defined for this validator
      Angegeben von:
      isValid in Schnittstelle Validator<T>
      Parameter:
      testValue - a String to be tested
      Gibt zurück:
      true if valid, false otherwise
    • assertValidity

      public void assertValidity(String testValue) throws ValidationException
      Determine whether a testValue meets the criteria specified in the constraints defined for this validator
      Angegeben von:
      assertValidity in Schnittstelle Validator<T>
      Parameter:
      testValue - a String to be tested
      Löst aus:
      ValidationException - containing an error message if the testValue did not pass the validation tests.
    • getMessage

      public String getMessage()
      Get the error message resulting from invalid input.
      Angegeben von:
      getMessage in Schnittstelle Validator<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

      public String getRequiredMessage()
      Get the value of requiredMessage.
      Gibt zurück:
      value of requiredMessage.
    • setRequiredMessage

      public void setRequiredMessage(String requiredMessage)
      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

      public String getMinLengthMessage()
      Get the value of minLengthMessage.
      Gibt zurück:
      value of minLengthMessage.
    • setMinLengthMessage

      public void setMinLengthMessage(String minLengthMessage)
      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

      public String getMaxLengthMessage()
      Get the value of maxLengthMessage.
      Gibt zurück:
      value of maxLengthMessage.
    • setMaxLengthMessage

      public void setMaxLengthMessage(String maxLengthMessage)
      Set the value of maxLengthMessage.
      Parameter:
      maxLengthMessage - Value to assign to maxLengthMessage.