biz.c24.io.api.data
Class ContextualValidationRule

java.lang.Object
  extended by biz.c24.io.api.data.DefaultValidationRule
      extended by biz.c24.io.api.data.ContextualValidationRule
All Implemented Interfaces:
ModelComponent, ValidationRule, Validator, Serializable

public class ContextualValidationRule
extends DefaultValidationRule

A validator implementation for context specific validation.

This validator allows the model to define at a high level a validation which should be applied to a value contained somewhere inside the complex type to which it is applied.

The actual value to be validated is retrieved by executing an XPath statement. The actual validation is done by a delgate validator

See Also:
Serialized Form

Constructor Summary
ContextualValidationRule(XPathStatement query, Validator validator)
          Creates a new contextual validator which will use the given XPath to lookup the value to validated against the supplied validator.
 
Method Summary
 XPathStatement getQuery()
          Returns the query to be executed to retrieve the value to be validated.
 Validator getValidator()
          Returns the validator to which the actual validation is delegated.
 void setQuery(XPathStatement query)
          Sets the query to be executed to retrieve the value to be validated.
 void setValidator(Validator validator)
          Sets the validator to which the actual validation is delegated.
 String toString()
           
 boolean validate(Object object, DataComponent component, ComplexDataObject context, ValidationManager manager)
          Validate the given object.
 
Methods inherited from class biz.c24.io.api.data.DefaultValidationRule
addDependentPredicateCode, getAnnotation, getContextForPredicateChecking, getDependentPredicateCode, getDependentPredicateCodeCount, getErrorCode, getName, getPredicateCode, getSeverity, removeDependentPredicateCode, setAnnotation, setErrorCode, setName, setPredicateCode, setSeverity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ContextualValidationRule

public ContextualValidationRule(XPathStatement query,
                                Validator validator)
Creates a new contextual validator which will use the given XPath to lookup the value to validated against the supplied validator.

Parameters:
query - The query to select the value to be validated.
validator - The validator to which the validation call is forwarded.
Throws:
NullPointerException - If either argument is null
Method Detail

validate

public boolean validate(Object object,
                        DataComponent component,
                        ComplexDataObject context,
                        ValidationManager manager)
                 throws ValidationException
Description copied from interface: Validator
Validate the given object.

Specified by:
validate in interface Validator
Overrides:
validate in class DefaultValidationRule
Parameters:
object - The object to be validated - commonly a String, Integer, Double, Date etc.
component - The Element or Attribute inside context which defines object.
context - The parent of object - could be null.
manager - The validation manager which is performing this validation.
Returns:
Whether the object is valid if the validation manager is not operating in exception mode.
Throws:
ValidationException - If the object is not valid and the validation maanger is operating in exception mode.

getQuery

public XPathStatement getQuery()
Returns the query to be executed to retrieve the value to be validated.

Returns:
The XPath query.

setQuery

public void setQuery(XPathStatement query)
Sets the query to be executed to retrieve the value to be validated.

Parameters:
query - The new value.

getValidator

public Validator getValidator()
Returns the validator to which the actual validation is delegated.

Returns:
The validator.

setValidator

public void setValidator(Validator validator)
Sets the validator to which the actual validation is delegated.

Parameters:
validator - The new value.

toString

public String toString()
Overrides:
toString in class DefaultValidationRule


C24 Technologies © 2002-2012: All Rights Reserved.