biz.c24.io.api.data
Class XQueryRule

java.lang.Object
  extended by biz.c24.io.api.data.DefaultValidationRule
      extended by biz.c24.io.api.data.XQueryRule
All Implemented Interfaces:
ModelComponent, ValidationRule, Validator, Serializable, net.sf.saxon.query.ModuleURIResolver

public class XQueryRule
extends DefaultValidationRule
implements net.sf.saxon.query.ModuleURIResolver

A validation rule which uses an XQuery expression to resolve a boolean value which determines whether the rule will pass or fail.

In the case of a failure the errorMessage attribute is passed to the validation mechanism.

Warning: Serialized objects of this class or of a deployed class which is derived from it may not be compatible with future releases of C24 Integreation Objects. The current serialization support is appropriate for short term storage or RMI between applications running the same version of C24 Integreation Objects.

See Also:
DomainConstraintManager, Serialized Form

Constructor Summary
XQueryRule()
          Creates a new instance.
 
Method Summary
 String getErrorMessage()
          Returns the error message which is used if the rule fails.
 XQueryStatement getQuery()
          Returns the XQuery statement which is evaluated to decide if the rule passes or fails.
 StreamSource[] resolve(String moduleURI, String baseURI, String[] locations)
          The implementation tries to resolve the location hint on the classpath only and return a StreamSource.
 void setErrorMessage(String errorMessage)
          Sets the error message which is used if the rule fails.
 void setQuery(XQueryStatement query)
          Sets the XQuery statement which is evaluated to decide if the rule passes or fails.
 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

XQueryRule

public XQueryRule()
Creates a new instance.

Method Detail

getQuery

public XQueryStatement getQuery()
Returns the XQuery statement which is evaluated to decide if the rule passes or fails.

Returns:
The XQuery statement.

setQuery

public void setQuery(XQueryStatement query)
Sets the XQuery statement which is evaluated to decide if the rule passes or fails.

Parameters:
statement - The statement.

getErrorMessage

public String getErrorMessage()
Returns the error message which is used if the rule fails.

Returns:
The error message.

setErrorMessage

public void setErrorMessage(String errorMessage)
Sets the error message which is used if the rule fails.

Parameters:
errorMessage - The error message.

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.

resolve

public StreamSource[] resolve(String moduleURI,
                              String baseURI,
                              String[] locations)
                       throws net.sf.saxon.trans.XPathException
The implementation tries to resolve the location hint on the classpath only and return a StreamSource. If a xquery resource could not be found it does not throw an exception and instead lets the default saxon resolver resolve the location hints.

Specified by:
resolve in interface net.sf.saxon.query.ModuleURIResolver
Parameters:
moduleURI - the module URI of the module to be imported; or null when loading a non-library module.
baseURI - The base URI of the module containing the "import module" declaration; null if no base URI is known.
locations - The set of URIs specified in the "at" clause of "import module", which serve as location hints for the module.
Throws:
net.sf.saxon.trans.XPathException

toString

public String toString()
Overrides:
toString in class DefaultValidationRule


C24 Technologies © 2002-2012: All Rights Reserved.