|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface AnnotationValidator<T>
Validation interface for validating objects annotated with JV annotations. The ValidationMessage contains a message containing the path of the method that was validated wrong. For instance the class:
class A {
private String example;
@JvGroup (name="1")
@NotNull
public String getExample() { .. }
}
Assume getExample() returns null, in that case a path of:
example is set with the error message. It is possible to use a prefix
where needed, use the appropriate method in that case. For instance setting a
prefix of: myInstance. would in this example result in an error path of: myInstance.example
In the current implementation, each AnnotationValidatorImpl loads its own configuration (read the xml configuration etc). So it would be wise to use the class as either singleton (e.g. make it a static variable somewhere and share in your application) or inject it using spring e.g. that its only instantiated once as well.
This implementation allows you to load multiple validators in the same JVM with different configurations if required.
Changes for 1.1:
| Method Summary | |
|---|---|
java.util.List<ValidationMessage> |
validateObject(T object)
Validates given object using the default primary group specified on ValidateDefinition. |
java.util.List<ValidationMessage> |
validateObject(T object,
java.lang.String group)
Validates given object for specified group, NOT recursive using a default path prefixing. |
java.util.List<ValidationMessage> |
validateObject(T object,
java.lang.String group,
boolean recurse)
Validates given object for specified group, either recursive or not using a default path prefixing. |
java.util.List<ValidationMessage> |
validateObject(T object,
java.lang.String group,
boolean recurse,
JavalidValidationCallbackHandler callbackHandler)
Validates given object for specified group, either recursive or not using a default path prefixing. |
java.util.List<ValidationMessage> |
validateObject(T object,
java.lang.String group,
JavalidValidationCallbackHandler callbackHandler)
Validates given object for specified group, NOT recursive using a default path prefixing. |
java.util.List<ValidationMessage> |
validateObject(T object,
java.lang.String group,
java.lang.String pathPrefix)
Validates given object for specified group using a special prefix (does not recurse). |
java.util.List<ValidationMessage> |
validateObject(T object,
java.lang.String group,
java.lang.String pathPrefix,
boolean recurse)
Validates given object for specified group using a special prefix and may recurse |
java.util.List<ValidationMessage> |
validateObject(T object,
java.lang.String group,
java.lang.String pathPrefix,
boolean recurse,
int levelDeep)
Validates given object for specified group using a special prefix and may recurse, if recurse is true levelDeep must be >= 1 |
java.util.List<ValidationMessage> |
validateObject(T object,
java.lang.String group,
java.lang.String pathPrefix,
boolean recurse,
int levelDeep,
JavalidValidationCallbackHandler callbackHandler)
Validates given object for specified group using a special prefix and may recurse, if recurse is true levelDeep must be >= 1. |
java.util.List<ValidationMessage> |
validateObject(T object,
java.lang.String group,
java.lang.String pathPrefix,
boolean recurse,
JavalidValidationCallbackHandler callbackHandler)
Validates given object for specified group using a special prefix and may recurse |
java.util.List<ValidationMessage> |
validateObject(T object,
java.lang.String group,
java.lang.String pathPrefix,
JavalidValidationCallbackHandler callbackHandler)
Validates given object for specified group using a special prefix (does not recurse). |
java.util.List<ValidationMessage> |
validateProperty(T owningObject,
java.lang.String groupName,
java.lang.Object propertyValue,
java.lang.String propertyName,
java.lang.String pathPrefix)
This method allows validation for a single property. |
| Method Detail |
|---|
java.util.List<ValidationMessage> validateObject(T object)
object - The object to validate
java.util.List<ValidationMessage> validateObject(T object,
java.lang.String group)
object - The object to validategroup - The group to validate
java.util.List<ValidationMessage> validateObject(T object,
java.lang.String group,
JavalidValidationCallbackHandler callbackHandler)
object - The object to validategroup - The group to validatecallbackHandler - Optional callbackhandler (any class that implements this interface). The framework will
then call the methods on this interface during validation. For details see the class
documentation itself.
JavalidValidationCallbackHandler
java.util.List<ValidationMessage> validateObject(T object,
java.lang.String group,
boolean recurse)
object - The object to validategroup - The group to validaterecurse - True if you wish to recurse (default 1 level deep)
java.util.List<ValidationMessage> validateObject(T object,
java.lang.String group,
boolean recurse,
JavalidValidationCallbackHandler callbackHandler)
object - The object to validategroup - The group to validaterecurse - True if you wish to recurse (default 1 level deep)callbackHandler - Optional callbackhandler (any class that implements this interface). The framework will
then call the methods on this interface during validation. For details see the class
documentation itself.
JavalidValidationCallbackHandler
java.util.List<ValidationMessage> validateObject(T object,
java.lang.String group,
java.lang.String pathPrefix)
object - The object to validategroup - The group to validatepathPrefix - The special path prefix to put before the normal object paths.
java.util.List<ValidationMessage> validateObject(T object,
java.lang.String group,
java.lang.String pathPrefix,
JavalidValidationCallbackHandler callbackHandler)
object - The object to validategroup - The group to validatepathPrefix - The special path prefix to put before the normal object paths.callbackHandler - Optional callbackhandler (any class that implements this interface). The framework will
then call the methods on this interface during validation. For details see the class
documentation itself.
JavalidValidationCallbackHandler
java.util.List<ValidationMessage> validateObject(T object,
java.lang.String group,
java.lang.String pathPrefix,
boolean recurse)
object - The object to validategroup - The group to validatepathPrefix - The special path prefix to put before the normal object paths.recurse - True if you wish to recurse (1 level deep)
java.util.List<ValidationMessage> validateObject(T object,
java.lang.String group,
java.lang.String pathPrefix,
boolean recurse,
JavalidValidationCallbackHandler callbackHandler)
object - The object to validategroup - The group to validatepathPrefix - The special path prefix to put before the normal object paths.recurse - True if you wish to recurse (1 level deep)callbackHandler - Optional callbackhandler (any class that implements this interface). The framework will
then call the methods on this interface during validation. For details see the class
documentation itself.
JavalidValidationCallbackHandler
java.util.List<ValidationMessage> validateObject(T object,
java.lang.String group,
java.lang.String pathPrefix,
boolean recurse,
int levelDeep)
object - The object to validategroup - The group to validatepathPrefix - The special path prefix to put before the normal object paths.recurse - True if you wish to recurselevelDeep - How deep the recursion should be, -1 for unlimited, otherwise >= 1. The recursion ends
when either levelDeep is reached or the instance working on does not have any getXXX methods
with JV group annotations anymore.
java.util.List<ValidationMessage> validateObject(T object,
java.lang.String group,
java.lang.String pathPrefix,
boolean recurse,
int levelDeep,
JavalidValidationCallbackHandler callbackHandler)
object - The object to validategroup - The group to validatepathPrefix - The special path prefix to put before the normal object paths.recurse - True if you wish to recurselevelDeep - How deep the recursion should be, -1 for unlimited, otherwise >= 1. The recursion ends
when either levelDeep is reached or the instance working on does not have any getXXX methods
with JV group annotations anymore.callbackHandler - Optional callbackhandler (any class that implements this interface). The framework will
then call the methods on this interface during validation. For details see the class
documentation itself.
JavalidValidationCallbackHandler
java.util.List<ValidationMessage> validateProperty(T owningObject,
java.lang.String groupName,
java.lang.Object propertyValue,
java.lang.String propertyName,
java.lang.String pathPrefix)
The owning object represents where the property is from (thus owningObject.propertyName together denotes the method under validation). The owning object is used to determine if validation is allowed what is supported etc. However other than for information the owningObject is not used (thus no method is called on it, instead we rely on propertyValue to validate that).
owningObject - The owning objectgroupName - Groupname we wish to validate for this propertypropertyValue - The actual value to validatepropertyName - The name of the property (is a methodname from the owningObject, we use that to determine
what validations must be processed on propertyValue), thus firstName is turned into getFirstName.pathPrefix - The prefix to use in the path, in this case it must be the full expression EXCLUDING the propertyName
but it should include owningObject's path (where it was from), e.g. in jsf: backingBean.person where
backingBean is the name of the jsf bean, and person matches our owningObject.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||