Class BaseValidator

  extended by org.iscreen.BaseValidator
All Implemented Interfaces:
Direct Known Subclasses:
DateFormatValidator, NullValidator, RegularExpressionValidator, StringValidator

public abstract class BaseValidator
extends java.lang.Object
implements Validator

This abstract class acts as a base class for custom validators. Sub-classes can extend this class to take advantage of the default implementation this class provides.

Shellman, Dan

Field Summary
protected  FailureMessage defaultFailure
Constructor Summary
Method Summary
 java.lang.Object constructBeanToValidate()
          This is called prior to calling the validate() method.
 FailureMessage getDefaultFailure()
          Retrieves the default failure message.
protected  java.lang.String getStringValue(java.lang.Object obj)
          Gets the object to validate as a String.
 void setDefaultFailure(FailureMessage failure)
          Sets the failure message.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.iscreen.Validator

Field Detail


protected FailureMessage defaultFailure
Constructor Detail


public BaseValidator()
Method Detail


public java.lang.Object constructBeanToValidate()
Description copied from interface: Validator
This is called prior to calling the validate() method. This method is meant to construct a JavaBean that will have properties mapped to it for use by the validator.

Specified by:
constructBeanToValidate in interface Validator
Returns a JavaBean that will have properties mapped to it for use by the call to the validate() method.


public FailureMessage getDefaultFailure()
Retrieves the default failure message. If only one failure is used by the sub-class, then this property can be used to get the failure message for reporting a failure.

Returns the default failure message.


public void setDefaultFailure(FailureMessage failure)
Sets the failure message. This is called based upon what's configured for this validator. Ensure that this is properly configured: otherwise, the call to getDefaultFailure() will return null.

failure - The default failure message to use.


protected java.lang.String getStringValue(java.lang.Object obj)
Gets the object to validate as a String. This method assumes the object is of type SimpleBean. If object is null, this method returns null; otherwise, it returns the value as a String.

This method would normally be called by the validate() method like this:
public void validate( ValidatorContext context, Object beanToValidate ) { String str; str = getStringValue( beanToValidate ); ... }

obj - The object being validated.
Returns the object to be validated as a String.