|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.oval.AbstractCheck
public abstract class AbstractCheck
Partial implementation of check classes.
Constructor Summary | |
---|---|
AbstractCheck()
|
Method Summary | |
---|---|
protected Map<String,? extends Serializable> |
createMessageVariables()
|
ConstraintTarget[] |
getAppliesTo()
In case the constraint is declared for an array, collection or map this controls how the constraint is applied to it and it's child objects. |
protected ConstraintTarget[] |
getAppliesToDefault()
|
OValContext |
getContext()
|
String |
getErrorCode()
|
String |
getMessage()
gets the default message that is displayed if a corresponding message key is not found in the messages properties file default processed place holders are:
|
Map<String,? extends Serializable> |
getMessageVariables()
Values that are used to fill place holders when rendering the error message. |
String[] |
getProfiles()
|
int |
getSeverity()
|
String |
getTarget()
An expression to specify where in the object graph relative from this object the expression should be applied. |
String |
getWhen()
Formula returning true if this constraint shall be evaluated and
false if it shall be ignored for the current validation. |
boolean |
isActive(Object validatedObject,
Object valueToValidate,
Validator validator)
|
protected void |
requireMessageVariablesRecreation()
Calling this method indicates that the createMessageVariables() method needs to be called before the message
for the next violation of this check is rendered. |
void |
setAppliesTo(ConstraintTarget... targets)
|
void |
setContext(OValContext context)
|
void |
setErrorCode(String failureCode)
|
void |
setMessage(String message)
sets the default message that is displayed if a corresponding message key is not found in the messages properties file default processed place holders are:
|
void |
setProfiles(String... profiles)
|
void |
setSeverity(int severity)
|
void |
setTarget(String target)
Sets an expression to specify where in the object graph relative from this object the expression should be applied. |
void |
setWhen(String when)
Sets the formula returning true if this constraint shall be evaluated and
false if it shall be ignored for the current validation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sf.oval.Check |
---|
isSatisfied |
Constructor Detail |
---|
public AbstractCheck()
Method Detail |
---|
protected Map<String,? extends Serializable> createMessageVariables()
public ConstraintTarget[] getAppliesTo()
In case the constraint is declared for an array, collection or map this controls how the constraint is applied to it and it's child objects.
Default: ConstraintTarget.CONTAINER
Note: This setting is ignored for object types other than array, map and collection.
getAppliesTo
in interface Check
protected ConstraintTarget[] getAppliesToDefault()
public OValContext getContext()
getContext
in interface Check
ClassContext
,
ConstraintSetContext
,
FieldContext
,
MethodEntryContext
,
MethodExitContext
,
MethodParameterContext
,
MethodReturnValueContext
public String getErrorCode()
getErrorCode
in interface Check
public String getMessage()
getMessage
in interface Check
public final Map<String,? extends Serializable> getMessageVariables()
createMessageVariables()
to create and fill the map
getMessageVariables
in interface Check
public String[] getProfiles()
getProfiles
in interface Check
public int getSeverity()
getSeverity
in interface Check
public String getTarget()
Check
Examples:
owner
owner
's property id
public String getWhen()
true
if this constraint shall be evaluated and
false
if it shall be ignored for the current validation.
Important: The formula must be prefixed with the name of the scripting language that is used.
E.g. groovy:_this.amount > 10
Available context variables are:
_this -> the validated bean
_value -> the value to validate (e.g. the field value, parameter value, method return value,
or the validated bean for object level constraints)
getWhen
in interface Check
public boolean isActive(Object validatedObject, Object valueToValidate, Validator validator)
isActive
in interface Check
validatedObject
- the object/bean to validate the value against, for static fields or methods this is the classvalueToValidate
- the value to validate, may be null when validating pre conditions for static methodsvalidator
- the calling validator
true
if this check is active and must be satisfiedprotected void requireMessageVariablesRecreation()
createMessageVariables()
method needs to be called before the message
for the next violation of this check is rendered.
public void setAppliesTo(ConstraintTarget... targets)
setAppliesTo
in interface Check
targets
- the constraint target to setpublic void setContext(OValContext context)
setContext
in interface Check
context
- the context to setpublic void setErrorCode(String failureCode)
setErrorCode
in interface Check
failureCode
- the error code to setpublic void setMessage(String message)
setMessage
in interface Check
public void setProfiles(String... profiles)
setProfiles
in interface Check
profiles
- the profiles to setpublic void setSeverity(int severity)
setSeverity
in interface Check
severity
- the severity to setpublic void setTarget(String target)
Check
Examples:
owner
owner
's property id
target
- the target to setpublic void setWhen(String when)
true
if this constraint shall be evaluated and
false
if it shall be ignored for the current validation.
Important: The formula must be prefixed with the name of the scripting language that is used.
E.g. groovy:_this.amount > 10
Available context variables are:
_this -> the validated bean
_value -> the value to validate (e.g. the field value, parameter value, method return value,
or the validated bean for object level constraints)
setWhen
in interface Check
when
- formula calculating if this check is active
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |