org.iscreen.validators
Class DateFormatValidator

java.lang.Object
  extended by org.iscreen.BaseValidator
      extended by org.iscreen.validators.DateFormatValidator
All Implemented Interfaces:
Validator

public class DateFormatValidator
extends BaseValidator

This validator checks the format of the input String to verify that it conforms to the proper format.

Author:
Shellman, Dan

Field Summary
protected  java.lang.String displayFormat
           
protected  java.lang.String format
           
protected  boolean lenientFlag
           
 
Fields inherited from class org.iscreen.BaseValidator
defaultFailure
 
Constructor Summary
DateFormatValidator()
          Default constructor.
 
Method Summary
 java.lang.String getDisplayFormat()
          Retrieves the format of the date for display purposes.
 java.lang.String getFormat()
          Retrieves the date format that the date is validated against.
 void setDisplayFormat(java.lang.String theDisplayFormat)
          The display format, which is reported when a failure occurs.
 void setFormat(java.lang.String theFormat)
          The format of the date String.
 void setLenient(boolean lenient)
          The lenient flag.
 void validate(ValidatorContext context, java.lang.Object beanToValidate)
          This is the method that's called to validate the "bean-to-validate." Use the passed in ValidatorContext to report validation failures, etc.
 
Methods inherited from class org.iscreen.BaseValidator
constructBeanToValidate, getDefaultFailure, getStringValue, getValue, setDefaultFailure
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

format

protected java.lang.String format

displayFormat

protected java.lang.String displayFormat

lenientFlag

protected boolean lenientFlag
Constructor Detail

DateFormatValidator

public DateFormatValidator()
Default constructor.

Method Detail

validate

public void validate(ValidatorContext context,
                     java.lang.Object beanToValidate)
Description copied from interface: Validator
This is the method that's called to validate the "bean-to-validate." Use the passed in ValidatorContext to report validation failures, etc. The passed-in "bean-to-validate" is the same instance returned from the call to constructBeanToValidate(), but with all of the appropriate properties set (based upon the configured mapping).

Parameters:
context - The ValidatorContext, which is used to report failures.
beanToValidate - The JavaBean to validate.

setFormat

public void setFormat(java.lang.String theFormat)
The format of the date String. The format should be a valid SimpleDateFormat pattern.

Parameters:
theFormat - The SimpleDateFormat pattern.

getFormat

public java.lang.String getFormat()
Retrieves the date format that the date is validated against.

Returns:
Returns the date format that the date is validated against.

setDisplayFormat

public void setDisplayFormat(java.lang.String theDisplayFormat)
The display format, which is reported when a failure occurs. It should be a human-readable format (defaults to MM/DD/YYYY).

Parameters:
theDisplayFormat - The format to display to the user.

getDisplayFormat

public java.lang.String getDisplayFormat()
Retrieves the format of the date for display purposes.

Returns:
Returns the format for the date for display purposes.

setLenient

public void setLenient(boolean lenient)
The lenient flag. Passed directly to the SimpleDateFormat that is used to validate the date String, this property defaults to false.

Parameters:
lenient - The lenient flag for the SimpleDateFormat.