com.opensymphony.xwork.validator.validators
Class ValidatorSupport

java.lang.Object
  extended by com.opensymphony.xwork.validator.validators.ValidatorSupport
All Implemented Interfaces:
ShortCircuitableValidator, Validator
Direct Known Subclasses:
ExpressionValidator, FieldValidatorSupport

public abstract class ValidatorSupport
extends Object
implements Validator, ShortCircuitableValidator

Abstract implementation of the Validator interface suitable for subclassing.

Version:
$Date: 2007-11-26 03:02:22 -0600 (Mon, 26 Nov 2007) $ $Id: ValidatorSupport.java 1687 2007-11-26 09:02:22Z tm_jee $
Author:
Jason Carreira, tmjee

Field Summary
protected  String defaultMessage
           
protected  org.apache.commons.logging.Log log
           
protected  String messageKey
           
 
Constructor Summary
ValidatorSupport()
           
 
Method Summary
protected  void addActionError(Object object)
           
protected  void addFieldError(String propertyName, Object object)
           
protected  Object conditionalParse(String expression)
          Parse expression passed in against value stack.
 String getDefaultMessage()
           
protected  Object getFieldValue(String name, Object object)
          Return the field value named name from object, object should have the appropriate getter/setter.
 String getMessage(Object object)
           
 String getMessageKey()
           
 String[] getMessageParameters()
           
 boolean getParse()
           
 ValidatorContext getValidatorContext()
           
 String getValidatorType()
           
 boolean isShortCircuit()
          Gets whether this field validator should short circuit the validator queue it's in if validation fails.
 void setDefaultMessage(String message)
           
 void setMessageKey(String key)
           
 void setMessageParameters(String[] messageParameters)
           
 void setParse(boolean parse)
           
 void setShortCircuit(boolean shortcircuit)
          Sets whether this field validator should short circuit the validator queue it's in if validation fails.
 void setValidatorContext(ValidatorContext validatorContext)
          This method will be called before validate with a non-null ValidatorContext.
 void setValidatorType(String type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.opensymphony.xwork.validator.Validator
validate
 

Field Detail

log

protected final org.apache.commons.logging.Log log

defaultMessage

protected String defaultMessage

messageKey

protected String messageKey
Constructor Detail

ValidatorSupport

public ValidatorSupport()
Method Detail

setParse

public void setParse(boolean parse)

getParse

public boolean getParse()

setDefaultMessage

public void setDefaultMessage(String message)
Specified by:
setDefaultMessage in interface Validator

getDefaultMessage

public String getDefaultMessage()
Specified by:
getDefaultMessage in interface Validator

getMessage

public String getMessage(Object object)
Specified by:
getMessage in interface Validator

setMessageKey

public void setMessageKey(String key)
Specified by:
setMessageKey in interface Validator

getMessageKey

public String getMessageKey()
Specified by:
getMessageKey in interface Validator

setMessageParameters

public void setMessageParameters(String[] messageParameters)
Specified by:
setMessageParameters in interface Validator

getMessageParameters

public String[] getMessageParameters()
Specified by:
getMessageParameters in interface Validator

setShortCircuit

public void setShortCircuit(boolean shortcircuit)
Description copied from interface: ShortCircuitableValidator
Sets whether this field validator should short circuit the validator queue it's in if validation fails.

Specified by:
setShortCircuit in interface ShortCircuitableValidator
Parameters:
shortcircuit - true if this field validator should short circuit on failure, false otherwise

isShortCircuit

public boolean isShortCircuit()
Description copied from interface: ShortCircuitableValidator
Gets whether this field validator should short circuit the validator queue it's in if validation fails.

Specified by:
isShortCircuit in interface ShortCircuitableValidator
Returns:
true if this field validator should short circuit on failure, false otherwise

setValidatorContext

public void setValidatorContext(ValidatorContext validatorContext)
Description copied from interface: Validator
This method will be called before validate with a non-null ValidatorContext.

Specified by:
setValidatorContext in interface Validator

getValidatorContext

public ValidatorContext getValidatorContext()
Specified by:
getValidatorContext in interface Validator

setValidatorType

public void setValidatorType(String type)
Specified by:
setValidatorType in interface Validator

getValidatorType

public String getValidatorType()
Specified by:
getValidatorType in interface Validator

conditionalParse

protected Object conditionalParse(String expression)
Parse expression passed in against value stack. Only parse when 'parse' param is set to true, else just returns the expression unparsed.

Parameters:
expression -
Returns:

getFieldValue

protected Object getFieldValue(String name,
                               Object object)
                        throws ValidationException
Return the field value named name from object, object should have the appropriate getter/setter.

Parameters:
name -
object -
Returns:
Throws:
ValidationException

addActionError

protected void addActionError(Object object)

addFieldError

protected void addFieldError(String propertyName,
                             Object object)

WebWork Project Page