Package org.eclipse.persistence.jaxb
Class JAXBValidator
- java.lang.Object
-
- org.eclipse.persistence.jaxb.JAXBValidator
-
-
Constructor Summary
Constructors Constructor Description JAXBValidator(XMLValidator newValidator)This constructor creates a DefaultValidationEventHandlervalidation instance, and sets the XMLMarshaller instance to the one provided.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ValidationEventHandlergetEventHandler()Return the current event handler or the default event handler if one hasn't been set.java.lang.ObjectgetProperty(java.lang.String key)Get the particular property in the underlying implementation ofValidator.voidsetEventHandler(ValidationEventHandler newValidationEventHandler)Allow an application to register a validation event handler.voidsetProperty(java.lang.String key, java.lang.Object value)Set the particular property in the underlying implementation ofValidator.booleanvalidate(java.lang.Object object)Validate a non-root object against a schema.booleanvalidateRoot(java.lang.Object rootObject)Validate a root object against a schema.
-
-
-
Constructor Detail
-
JAXBValidator
public JAXBValidator(XMLValidator newValidator)
This constructor creates a DefaultValidationEventHandlervalidation instance, and sets the XMLMarshaller instance to the one provided.- Parameters:
newValidator-
-
-
Method Detail
-
validateRoot
public boolean validateRoot(java.lang.Object rootObject) throws JAXBExceptionValidate a root object against a schema.- Specified by:
validateRootin interfaceValidator- Parameters:
rootObject- - the root object to be validated- Returns:
- true if a valid root object, false otherwise
- Throws:
JAXBExceptionValidationException- If theValidationEventHandlerreturns false from itshandleEventmethod or theValidatoris unable to validate the content tree rooted atrootObj
-
validate
public boolean validate(java.lang.Object object) throws JAXBExceptionValidate a non-root object against a schema.- Specified by:
validatein interfaceValidator- Parameters:
object- - the object to be validated- Returns:
- true if a valid object, false otherwise
- Throws:
JAXBExceptionValidationException- If theValidationEventHandlerreturns false from itshandleEventmethod or theValidatoris unable to validate the content tree rooted atsubrootObj
-
setEventHandler
public void setEventHandler(ValidationEventHandler newValidationEventHandler) throws JAXBException
Description copied from interface:ValidatorAllow 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:
setEventHandlerin interfaceValidator- 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:ValidatorReturn the current event handler or the default event handler if one hasn't been set.- Specified by:
getEventHandlerin interfaceValidator- 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 PropertyExceptionDescription copied from interface:ValidatorSet the particular property in the underlying implementation ofValidator. 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:
setPropertyin interfaceValidator- 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 PropertyExceptionDescription copied from interface:ValidatorGet the particular property in the underlying implementation ofValidator. 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:
getPropertyin interfaceValidator- 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
-
-