EclipseLink 2.2.0, build 'v20110202-r8913' API Reference

org.eclipse.persistence.jaxb
Class JAXBValidator

java.lang.Object
  extended by org.eclipse.persistence.jaxb.JAXBValidator
All Implemented Interfaces:
Validator

public class JAXBValidator
extends java.lang.Object
implements Validator

Facilitates JAXBValidation.


Constructor Summary
JAXBValidator(XMLValidator newValidator)
          This constructor creates a DefaultValidationEventHandlervalidation instance, and sets the XMLMarshaller instance to the one provided.
 
Method Summary
 ValidationEventHandler getEventHandler()
          Return the current event handler or the default event handler if one hasn't been set.
 java.lang.Object getProperty(java.lang.String key)
          Get the particular property in the underlying implementation of Validator.
 void setEventHandler(ValidationEventHandler newValidationEventHandler)
          Allow an application to register a validation event handler.
 void setProperty(java.lang.String key, java.lang.Object value)
          Set the particular property in the underlying implementation of Validator.
 boolean validate(java.lang.Object object)
          Validate a non-root object against a schema.
 boolean validateRoot(java.lang.Object rootObject)
          Validate a root object against a schema.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JAXBValidator

public JAXBValidator(XMLValidator newValidator)
This constructor creates a DefaultValidationEventHandlervalidation instance, and sets the XMLMarshaller instance to the one provided.

Parameters:
newXMLMarshaller -
Method Detail

validateRoot

public boolean validateRoot(java.lang.Object rootObject)
                     throws JAXBException
Validate a root object against a schema.

Specified by:
validateRoot in interface Validator
Parameters:
rootObject - - the root object to be validated
Returns:
true if a valid root object, false otherwise
Throws:
JAXBException
ValidationException - If the ValidationEventHandler returns false from its handleEvent method or the Validator is unable to validate the content tree rooted at rootObj

validate

public boolean validate(java.lang.Object object)
                 throws JAXBException
Validate a non-root object against a schema.

Specified by:
validate in interface Validator
Parameters:
object - - the object to be validated
Returns:
true if a valid object, false otherwise
Throws:
JAXBException
ValidationException - If the ValidationEventHandler returns false from its handleEvent method or the Validator is unable to validate the content tree rooted at subrootObj

setEventHandler

public void setEventHandler(ValidationEventHandler newValidationEventHandler)
                     throws JAXBException
Description copied from interface: Validator
Allow an application to register a validation event handler.

The validation event handler will be called by the JAXB Provider if any validation errors are encountered during calls to validate. If the client application does not register a validation event handler before invoking the validate method, then validation events will be handled by the default event handler which will terminate the validate operation after the first error or fatal error is encountered.

Calling this method with a null parameter will cause the Validator to revert back to the default default event handler.

Specified by:
setEventHandler in interface Validator
Parameters:
newValidationEventHandler - the validation event handler
Throws:
JAXBException - if an error was encountered while setting the event handler

getEventHandler

public ValidationEventHandler getEventHandler()
                                       throws JAXBException
Description copied from interface: Validator
Return the current event handler or the default event handler if one hasn't been set.

Specified by:
getEventHandler in interface Validator
Returns:
the current ValidationEventHandler or the default event handler if it hasn't been set
Throws:
JAXBException - if an error was encountered while getting the current event handler

setProperty

public void setProperty(java.lang.String key,
                        java.lang.Object value)
                 throws PropertyException
Description copied from interface: Validator
Set the particular property in the underlying implementation of Validator. This method can only be used to set one of the standard JAXB defined properties above or a provider specific property. Attempting to set an undefined property will result in a PropertyException being thrown. See Supported Properties.

Specified by:
setProperty in interface Validator
Parameters:
key - the name of the property to be set. This value can either be specified using one of the constant fields or a user supplied string.
value - the value of the property to be set
Throws:
PropertyException - when there is an error processing the given property or value

getProperty

public java.lang.Object getProperty(java.lang.String key)
                             throws PropertyException
Description copied from interface: Validator
Get the particular property in the underlying implementation of Validator. This method can only be used to get one of the standard JAXB defined properties above or a provider specific property. Attempting to get an undefined property will result in a PropertyException being thrown. See Supported Properties.

Specified by:
getProperty in interface Validator
Parameters:
key - the name of the property to retrieve
Returns:
the value of the requested property
Throws:
PropertyException - when there is an error retrieving the given property or value property name

EclipseLink 2.2.0, build 'v20110202-r8913' API Reference