org.springmodules.validation.bean.rule
Class DefaultValidationRule

java.lang.Object
  extended by org.springmodules.validation.bean.rule.DefaultValidationRule
All Implemented Interfaces:
ValidationRule

public class DefaultValidationRule
extends Object
implements ValidationRule

The default implementation of the ValidationRule interface. This implementation uses an applicability condition to determine whether this rule is applicable on a given object (see ValidationRule.isApplicable(Object)).

Author:
Uri Boness

Constructor Summary
DefaultValidationRule()
          Empty contructor (javabean support).
DefaultValidationRule(Condition condition, Condition applicabilityCondition, String errorCode)
          Constructs a new DefaultValidationRule with given condition and error code.
DefaultValidationRule(Condition condition, Condition applicabilityCondition, String errorCode, Object[] errorArguments)
          Constructs a new DefaultValidationRule with given condition, error code, and error arguments.
DefaultValidationRule(Condition condition, Condition applicabilityCondition, String errorCode, String defalutErrorMessage, ErrorArgumentsResolver errorArgumentsResolver)
          Constructs a new DefaultValidationRule with given condition, error code, error arguments resolver, and default error message.
DefaultValidationRule(Condition condition, Condition applicabilityCondition, String errorCode, String defalutErrorMessage, Object[] errorArguments)
          Constructs a new DefaultValidationRule with given condition, error code, error arguments, and default error message.
DefaultValidationRule(Condition condition, String errorCode)
          Constructs a new DefaultValidationRule with the given condition and error code.
DefaultValidationRule(Condition condition, String errorCode, Object[] errorArguments)
          Constructs a new DefaultValidationRule with the given condition, error code, and error arguments.
DefaultValidationRule(Condition condition, String errorCode, String defalutErrorMessage, Object[] errorArguments)
          Constructs a new DefaultValidationRule with the given condition and error information.
 
Method Summary
 Condition getApplicabilityCondition()
          Returns the applicability condition of this validation rule.
 Condition getCondition()
          see ValidationRule.getCondition()
 String getDefaultErrorMessage()
          See ValidationRule.getDefaultErrorMessage().
 Object[] getErrorArguments(Object obj)
          See ValidationRule.getErrorArguments(Object)
 String getErrorCode()
          See ValidationRule.getErrorCode()
 boolean isApplicable(Object obj)
          see ValidationRule.isApplicable(Object).
 void setApplicabilityCondition(Condition applicabilityCondition)
          Sets the applicability condition of this validation rule. see getApplicabilityCondition().
 void setCondition(Condition condition)
          Sets the condition of this validation rule. see getCondition().
 void setDefalutErrorMessage(String defalutErrorMessage)
          Sets the default error message to be used in case no error message is associated with the error code of this validation rule.
 void setErrorArguments(Object[] errorArguments)
          Sets the arguments to attach to the error code of this validation rule. see getErrorArguments(Object).
 void setErrorArgumentsResolver(ErrorArgumentsResolver errorArgumentsResolver)
          Sets the error arguments resolver to be used by this validation rule to resolve the error arguments.
 void setErrorCode(String errorCode)
          Sets the error code of this validation rule. see getErrorCode().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultValidationRule

public DefaultValidationRule()
Empty contructor (javabean support).


DefaultValidationRule

public DefaultValidationRule(Condition condition,
                             String errorCode)
Constructs a new DefaultValidationRule with the given condition and error code. The condition is always applicable.

Parameters:
condition - The condition of this validation rule.
errorCode - The error code of this validation rule.

DefaultValidationRule

public DefaultValidationRule(Condition condition,
                             String errorCode,
                             Object[] errorArguments)
Constructs a new DefaultValidationRule with the given condition, error code, and error arguments. The condition is always applicable.

Parameters:
condition - The condition of this validation rule.
errorCode - The error code of this validation rule.
errorArguments - The error arguments of this validation rule.

DefaultValidationRule

public DefaultValidationRule(Condition condition,
                             String errorCode,
                             String defalutErrorMessage,
                             Object[] errorArguments)
Constructs a new DefaultValidationRule with the given condition and error information. The condition is always applicable.

Parameters:
condition - The condition of this validation rule.
errorCode - The error code of this validation rule.
defalutErrorMessage - The default error message of this validation rule.
errorArguments - The error arguments of this validation rule.

DefaultValidationRule

public DefaultValidationRule(Condition condition,
                             Condition applicabilityCondition,
                             String errorCode)
Constructs a new DefaultValidationRule with given condition and error code. The applicability of this rule is determined by the given applicability condition.

Parameters:
condition - The condition of this validation rule.
applicabilityCondition - Determines whether this rule is applicable on a given object.
errorCode - The error code of this validation rule.

DefaultValidationRule

public DefaultValidationRule(Condition condition,
                             Condition applicabilityCondition,
                             String errorCode,
                             Object[] errorArguments)
Constructs a new DefaultValidationRule with given condition, error code, and error arguments. The applicability of this rule is determined by the given applicability condition.

Parameters:
condition - The condition of this validation rule.
applicabilityCondition - Determines whether this rule is applicable on a given object.
errorCode - The error code of this validation rule.
errorArguments - The error arguments of this validation rule.

DefaultValidationRule

public DefaultValidationRule(Condition condition,
                             Condition applicabilityCondition,
                             String errorCode,
                             String defalutErrorMessage,
                             Object[] errorArguments)
Constructs a new DefaultValidationRule with given condition, error code, error arguments, and default error message. The applicability of this rule is determined by the given applicability condition.

Parameters:
condition - The condition of this validation rule.
applicabilityCondition - Determines whether this rule is applicable on a given object.
errorCode - The error code of this validation rule.
defalutErrorMessage - The default error message of this validation rule.
errorArguments - The error arguments of this validation rule.

DefaultValidationRule

public DefaultValidationRule(Condition condition,
                             Condition applicabilityCondition,
                             String errorCode,
                             String defalutErrorMessage,
                             ErrorArgumentsResolver errorArgumentsResolver)
Constructs a new DefaultValidationRule with given condition, error code, error arguments resolver, and default error message. The applicability of this rule is determined by the given applicability condition.

Parameters:
condition - The condition of this validation rule.
applicabilityCondition - Determines whether this rule is applicable on a given object.
errorCode - The error code of this validation rule.
defalutErrorMessage - The default error message of this validation rule.
errorArgumentsResolver - The resolver that will be used to resolve the error arguments.
Method Detail

isApplicable

public boolean isApplicable(Object obj)
see ValidationRule.isApplicable(Object).

The applicability of this validation rule is determined by the applicability condition. see getApplicabilityCondition().

Specified by:
isApplicable in interface ValidationRule
Parameters:
obj - The object to be validated
Returns:
True if this validation rule is applicable on the given obj, false otherwise.

getCondition

public Condition getCondition()
see ValidationRule.getCondition()

Specified by:
getCondition in interface ValidationRule
Returns:
The condition of this validation rule.

setCondition

public void setCondition(Condition condition)
Sets the condition of this validation rule. see getCondition().

Parameters:
condition - The condition of this validation rule.

getErrorCode

public String getErrorCode()
See ValidationRule.getErrorCode()

Specified by:
getErrorCode in interface ValidationRule
Returns:
The error code of this validation rule.

setErrorCode

public void setErrorCode(String errorCode)
Sets the error code of this validation rule. see getErrorCode().

Parameters:
errorCode - The error code of this validation rule.

getErrorArguments

public Object[] getErrorArguments(Object obj)
See ValidationRule.getErrorArguments(Object)

Specified by:
getErrorArguments in interface ValidationRule
Parameters:
obj - The validated object.
Returns:
The arguments that apply to the error code of this validation rule.

setErrorArguments

public void setErrorArguments(Object[] errorArguments)
Sets the arguments to attach to the error code of this validation rule. see getErrorArguments(Object).

Parameters:
errorArguments - The arguments to attach to the error code of this validation rule.

setErrorArgumentsResolver

public void setErrorArgumentsResolver(ErrorArgumentsResolver errorArgumentsResolver)
Sets the error arguments resolver to be used by this validation rule to resolve the error arguments.

Parameters:
errorArgumentsResolver - The given error arguments resolver.

getDefaultErrorMessage

public String getDefaultErrorMessage()
See ValidationRule.getDefaultErrorMessage().

Specified by:
getDefaultErrorMessage in interface ValidationRule
Returns:
The default error message of this validation rule.

setDefalutErrorMessage

public void setDefalutErrorMessage(String defalutErrorMessage)
Sets the default error message to be used in case no error message is associated with the error code of this validation rule. See getDefaultErrorMessage().

Parameters:
defalutErrorMessage - The default error message of this validation rule.

getApplicabilityCondition

public Condition getApplicabilityCondition()
Returns the applicability condition of this validation rule. This applicability condition determines whether this validation rule is applicable for a given object.

Returns:
The applicability condition of this validation rule.

setApplicabilityCondition

public void setApplicabilityCondition(Condition applicabilityCondition)
Sets the applicability condition of this validation rule. see getApplicabilityCondition().

Parameters:
applicabilityCondition - The applicability condition of this validation rule.


Copyright © 2009. All Rights Reserved.