|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springmodules.validation.bean.rule.AbstractValidationRule
public abstract class AbstractValidationRule
A super class for all specific validation rules.
Constructor Summary | |
---|---|
protected |
AbstractValidationRule(String defaultErrorCode)
Constructs a new AbstractValidationRule with a default error code. |
protected |
AbstractValidationRule(String defaultErrorCode,
ErrorArgumentsResolver defaultErrorArgumentsResolver)
Constructs a new AbstractValidationRule with a default error code and error argument resolver. |
Method Summary | |
---|---|
protected static boolean |
checkContexts(String[] contextTokens)
|
protected static ErrorArgumentsResolver |
createErrorArgumentsResolver(Object arg)
A helper method for sub-classes helping with the creation of error argument resolvers. |
protected static ErrorArgumentsResolver |
createErrorArgumentsResolver(Object[] arguments)
A helper method for sub-classes helping with the creation of error argument resolvers. |
protected static ErrorArgumentsResolver |
createErrorArgumentsResolver(Object arg1,
Object arg2)
A helper method for sub-classes helping with the creation of error argument resolvers. |
protected static ErrorArgumentsResolver |
createErrorArgumentsResolver(Object arg1,
Object arg2,
Object arg3)
A helper method for sub-classes helping with the creation of error argument resolvers. |
String |
getDefaultErrorMessage()
Returns the default error message that can be used in case no error message is bound to the error code of the rule. |
Object[] |
getErrorArguments(Object obj)
Returns the error arguments for this validation rule based on the given validated object. |
String |
getErrorCode()
Return the error code of this validation rule. |
boolean |
isApplicable(Object obj)
Checks if this validation rule is applicable on a given object by performing the following two steps: If the object is null and supportsNullValues() returns false
then returning false . |
void |
setApplicabilityCondition(Condition applicabilityCondition)
Sets the applicability condition that along with the supportsNullValues() method determines whether
this condition is applicable on a given object or not. |
void |
setContextTokens(String[] contextTokens)
Sets the validation contexts names in which this validation rule is applicable. |
void |
setDefaultErrorMessage(String defaultErrorMessage)
Sets the default error message of this validation rule. |
void |
setErrorArgumentsResolver(ErrorArgumentsResolver errorArgumentsResolver)
Sets the ErrorArgumentsResolver that will be used by this validation to extract the error arguments
based on the validated object. |
void |
setErrorCode(String errorCode)
Sets the error code of this validation rule. |
protected boolean |
supportsNullValues()
Determines whether this validation rule supports null values. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.springmodules.validation.bean.rule.ValidationRule |
---|
getCondition |
Constructor Detail |
---|
protected AbstractValidationRule(String defaultErrorCode)
defaultErrorCode
- protected AbstractValidationRule(String defaultErrorCode, ErrorArgumentsResolver defaultErrorArgumentsResolver)
defaultErrorCode
- The default error code for this validation rule.defaultErrorArgumentsResolver
- The argument resolver for this validation rule.Method Detail |
---|
public boolean isApplicable(Object obj)
null
and supportsNullValues()
returns false
then returning false
.setApplicabilityCondition(org.springmodules.validation.util.condition.Condition)
)
isApplicable
in interface ValidationRule
obj
- The object to be validated
ValidationRule.isApplicable(Object)
public String getErrorCode()
ValidationRule
null
.
getErrorCode
in interface ValidationRule
ValidationRule.getErrorCode()
public Object[] getErrorArguments(Object obj)
ErrorArgumentsResolver
.
getErrorArguments
in interface ValidationRule
obj
- The validated object.
setErrorArgumentsResolver(org.springmodules.validation.bean.rule.resolver.ErrorArgumentsResolver)
,
ValidationRule.getErrorArguments(Object)
public String getDefaultErrorMessage()
ValidationRule
null
to indicate that
no default message exists.
getDefaultErrorMessage
in interface ValidationRule
ValidationRule.getDefaultErrorMessage()
protected boolean supportsNullValues()
null
values. This method by default returns false,
any sub-class that supports null
values should override this method and return true
.
null
values.public void setErrorCode(String errorCode)
errorCode
- The error code of this validation rule.public void setDefaultErrorMessage(String defaultErrorMessage)
defaultErrorMessage
- The default error message of this validation rule.public void setErrorArgumentsResolver(ErrorArgumentsResolver errorArgumentsResolver)
ErrorArgumentsResolver
that will be used by this validation to extract the error arguments
based on the validated object.
errorArgumentsResolver
- The error argument resolver that will be used by this validator.public void setApplicabilityCondition(Condition applicabilityCondition)
supportsNullValues()
method determines whether
this condition is applicable on a given object or not.
applicabilityCondition
- The applicability condition that will be used by this validation rule when deciding
whether it is applicable on a given object.public void setContextTokens(String[] contextTokens)
contextTokens
- The validation context names in which this validation rule is applicable. null
represents applicability in any context (even if one doesn't exsit).protected static ErrorArgumentsResolver createErrorArgumentsResolver(Object arg)
arg
as the error
arguments.
arg
- The error argument to be returned along with the validated object.
protected static ErrorArgumentsResolver createErrorArgumentsResolver(Object arg1, Object arg2)
arg1
- The error argument to be returned in position {1}arg2
- The error argument to be returned in position {2}
protected static ErrorArgumentsResolver createErrorArgumentsResolver(Object arg1, Object arg2, Object arg3)
arg1
- The error argument to be returned in position {1}arg2
- The error argument to be returned in position {2}arg3
- The error argument to be returned in position {3}
protected static ErrorArgumentsResolver createErrorArgumentsResolver(Object[] arguments)
arguments
- The error arguments that will be return along with the validated object, starting in position {1}.
protected static boolean checkContexts(String[] contextTokens)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |