uk.org.ogsadai.common
Class DocumentValidator

java.lang.Object
  |
  +--uk.org.ogsadai.common.DocumentValidator
Direct Known Subclasses:
ActivityClassDocumentValidator, ActivityPropertyDocumentValidator, ConfigurableActivitiesDocumentValidator, SchemaDocumentValidator, UnknownActivityDocumentValidator

public abstract class DocumentValidator
extends java.lang.Object

A DocumentValidator validates a Document and throws a DocumentValidationException with a descriptive error message if it is deemend invalid. This abstract base class uses a variation of the Chain of Command design pattern, so a sequence of document validators can be chained together using the setSuccessor method. The document passed to the first document validator's validate method will then pass along the chain until either a DocumentValidationException is raised or the end of the chain is reached. Implementation classes must implement the abstract performValidation method.

Author:
The OGSA-DAI Project Team

Constructor Summary
DocumentValidator()
           
 
Method Summary
protected abstract  void performValidation(org.w3c.dom.Document request)
          Validates the specified document and throws a DocumentValidationException with a desctiptive error message if the document is invalid.
 void setSuccessor(DocumentValidator validator)
          Sets the next DocumentValidator in the chain.
 void validate(org.w3c.dom.Document performDocument)
          Validates the specified document then, if an exception has not been raised, passes it on to the next document validator in the chain, if the end of the chain has not been reached.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentValidator

public DocumentValidator()
Method Detail

setSuccessor

public final void setSuccessor(DocumentValidator validator)
Sets the next DocumentValidator in the chain.

Parameters:
validator - a DocumentValidator

validate

public final void validate(org.w3c.dom.Document performDocument)
                    throws DocumentValidationException
Validates the specified document then, if an exception has not been raised, passes it on to the next document validator in the chain, if the end of the chain has not been reached.

Parameters:
performDocument - the document to validate
Throws:
DocumentValidationException - if the document is invalid

performValidation

protected abstract void performValidation(org.w3c.dom.Document request)
                                   throws DocumentValidationException
Validates the specified document and throws a DocumentValidationException with a desctiptive error message if the document is invalid. This method must be implemented by DocumentValidator implementations.

Parameters:
request - the document to validate
Throws:
DocumentValidationException - if the document is invalid