org.apache.turbine.services.intake.validator
Class DefaultValidator

java.lang.Object
  |
  +--org.apache.turbine.services.intake.validator.DefaultValidator
All Implemented Interfaces:
InitableByConstraintMap, Validator
Direct Known Subclasses:
NumberValidator

public class DefaultValidator
extends java.lang.Object
implements Validator, InitableByConstraintMap

A validator that will compare a testValue against the following constraints:
NameValid ValuesDefault Value
requiredtrue|falsefalse
maskregexp 
minLengthinteger0
maxLengthinteger 
This validator can serve as the base class for more specific validators

Version:
$Id: DefaultValidator.java,v 1.1.1.1 2001/08/16 05:08:58 jvanzyl Exp $
Author:
John McNally

Field Summary
protected  org.apache.regexp.RE mask
           
protected  java.lang.String maskMessage
           
protected  int maxLength
           
protected  java.lang.String maxLengthMessage
           
protected  java.lang.String message
           
protected  int minLength
           
protected  java.lang.String minLengthMessage
           
protected  boolean required
           
protected  java.lang.String requiredMessage
           
 
Constructor Summary
DefaultValidator()
           
DefaultValidator(java.util.Map paramMap)
           
 
Method Summary
 void assertValidity(java.lang.String testValue)
          Determine whether a testValue meets the criteria specified in the constraints defined for this validator
protected  void doAssertValidity(java.lang.String testValue)
          Method to allow subclasses to add additional validation
 java.lang.String getMask()
          Get the value of mask.
 java.lang.String getMaskMessage()
          Get the value of maskMessage.
 int getMaxLength()
          Get the value of maxLength.
 java.lang.String getMaxLengthMessage()
          Get the value of maxLengthMessage.
 java.lang.String getMessage()
          Get the last error message resulting from invalid input.
 int getMinLength()
          Get the value of minLength.
 java.lang.String getMinLengthMessage()
          Get the value of minLengthMessage.
 java.lang.String getRequiredMessage()
          Get the value of requiredMessage.
 void init(java.util.Map paramMap)
          Extract the relevant parameters from the constraints listed in tags within the intake.xml file.
 boolean isRequired()
          Get the value of required.
 boolean isValid(java.lang.String testValue)
          Determine whether a testValue meets the criteria specified in the constraints defined for this validator
 void setMask(java.lang.String v)
          Set the value of mask.
 void setMaskMessage(java.lang.String v)
          Set the value of maskMessage.
 void setMaxLength(int v)
          Set the value of maxLength.
 void setMaxLengthMessage(java.lang.String v)
          Set the value of maxLengthMessage.
 void setMinLength(int v)
          Set the value of minLength.
 void setMinLengthMessage(java.lang.String v)
          Set the value of minLengthMessage.
 void setRequired(boolean v)
          Set the value of required.
 void setRequiredMessage(java.lang.String v)
          Set the value of requiredMessage.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

required

protected boolean required

requiredMessage

protected java.lang.String requiredMessage

mask

protected org.apache.regexp.RE mask

maskMessage

protected java.lang.String maskMessage

minLength

protected int minLength

minLengthMessage

protected java.lang.String minLengthMessage

maxLength

protected int maxLength

maxLengthMessage

protected java.lang.String maxLengthMessage

message

protected java.lang.String message
Constructor Detail

DefaultValidator

public DefaultValidator(java.util.Map paramMap)
                 throws TurbineException

DefaultValidator

public DefaultValidator()
Method Detail

init

public void init(java.util.Map paramMap)
          throws TurbineException
Extract the relevant parameters from the constraints listed in tags within the intake.xml file.
Specified by:
init in interface InitableByConstraintMap
Parameters:
paramMap - a Map of Rule's containing constraints on the input.
Throws:
TurbineException - if an error occurs

isValid

public boolean isValid(java.lang.String testValue)
Determine whether a testValue meets the criteria specified in the constraints defined for this validator
Specified by:
isValid in interface Validator
Parameters:
testValue - a String to be tested
Returns:
true if valid, false otherwise

assertValidity

public void assertValidity(java.lang.String testValue)
                    throws ValidationException
Determine whether a testValue meets the criteria specified in the constraints defined for this validator
Specified by:
assertValidity in interface Validator
Parameters:
testValue - a String to be tested
Throws:
ValidationException - containing an error message if the testValue did not pass the validation tests.

getMessage

public java.lang.String getMessage()
Get the last error message resulting from invalid input.
Specified by:
getMessage in interface Validator
Returns:
a String message, or the empty String "".

doAssertValidity

protected void doAssertValidity(java.lang.String testValue)
                         throws ValidationException
Method to allow subclasses to add additional validation

isRequired

public boolean isRequired()
Get the value of required.
Returns:
value of required.

setRequired

public void setRequired(boolean v)
Set the value of required.
Parameters:
v - Value to assign to required.

getRequiredMessage

public java.lang.String getRequiredMessage()
Get the value of requiredMessage.
Returns:
value of requiredMessage.

setRequiredMessage

public void setRequiredMessage(java.lang.String v)
Set the value of requiredMessage.
Parameters:
v - Value to assign to requiredMessage.

getMask

public java.lang.String getMask()
Get the value of mask.
Returns:
value of mask.

setMask

public void setMask(java.lang.String v)
             throws TurbineException
Set the value of mask.
Parameters:
v - Value to assign to mask.

getMaskMessage

public java.lang.String getMaskMessage()
Get the value of maskMessage.
Returns:
value of maskMessage.

setMaskMessage

public void setMaskMessage(java.lang.String v)
Set the value of maskMessage.
Parameters:
v - Value to assign to maskMessage.

getMinLength

public int getMinLength()
Get the value of minLength.
Returns:
value of minLength.

setMinLength

public void setMinLength(int v)
Set the value of minLength.
Parameters:
v - Value to assign to minLength.

getMinLengthMessage

public java.lang.String getMinLengthMessage()
Get the value of minLengthMessage.
Returns:
value of minLengthMessage.

setMinLengthMessage

public void setMinLengthMessage(java.lang.String v)
Set the value of minLengthMessage.
Parameters:
v - Value to assign to minLengthMessage.

getMaxLength

public int getMaxLength()
Get the value of maxLength.
Returns:
value of maxLength.

setMaxLength

public void setMaxLength(int v)
Set the value of maxLength.
Parameters:
v - Value to assign to maxLength.

getMaxLengthMessage

public java.lang.String getMaxLengthMessage()
Get the value of maxLengthMessage.
Returns:
value of maxLengthMessage.

setMaxLengthMessage

public void setMaxLengthMessage(java.lang.String v)
Set the value of maxLengthMessage.
Parameters:
v - Value to assign to maxLengthMessage.


Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.