javax.xml.bind

Interface Validator

public interface Validator

A Validator may be used to decide, whether a JAXB object is valid or not. If it is not, the JAXB user may decide to trigger an exception or not (via the ValidationEventHandler and he may receive information on the problems location (via the event handlers ValidationEventLocator.

A Validator may be present implicitly, invoked by the Unmarshaller. See Unmarshaller for more information on that.

Since: JAXB1.0

Author: JSR-31

See Also: ValidationEventHandler ValidationEvent

Method Summary
ValidationEventHandlergetEventHandler()

Returns an event handler that shall be invoked for notifications on problems detected by the Validator.

ObjectgetProperty(String pName)

Returns the marshallers property pName.

Note: The values type depends on the property name.

voidsetEventHandler(ValidationEventHandler pHandler)

Registers an event handler that shall be invoked for notifications on problems detected by the Validator.

voidsetProperty(String pName, Object pValue)

Sets the Validator property pName to pValue.

Note: The values type depends on the property name.

booleanvalidate(Object pObject)

Validates the given JAXB object, invoking its error handler for any problems it detects.

booleanvalidateRoot(Object pObject)

Validates the given JAXB object, but not its child elements.

Method Detail

getEventHandler

public ValidationEventHandler getEventHandler()

Returns an event handler that shall be invoked for notifications on problems detected by the Validator. If no specific event handler was set, returns the default event handler. The default event handler will trigger an exception for errors and fatal errors.

Returns: The event handler previously set or the default handler.

Throws: JAXBException Getting the event handler failed.

getProperty

public Object getProperty(String pName)

Returns the marshallers property pName.

Note: The values type depends on the property name.

Parameters: pName The property name.

Returns: The property value.

Throws: PropertyException Fetching the property failed. IllegalArgumentException The parameter was null.

setEventHandler

public void setEventHandler(ValidationEventHandler pHandler)

Registers an event handler that shall be invoked for notifications on problems detected by the Validator. If this method is not invoked, there is a default event handler. The default event handler will trigger an exception for errors and fatal errors.

Parameters: pHandler The event handler being notified or null to restore the default event handler.

Throws: JAXBException Setting the event handler failed.

setProperty

public void setProperty(String pName, Object pValue)

Sets the Validator property pName to pValue.

Note: The values type depends on the property name.

Parameters: pName The property name. pValue The property value.

Throws: PropertyException Setting the property failed. IllegalArgumentException The pName parameter was null.

validate

public boolean validate(Object pObject)

Validates the given JAXB object, invoking its error handler for any problems it detects. Detected problems may cause exceptions, for example, if the event handlers handleEvent method returns false.

Parameters: pObject The JAXB object being validated.

Throws: JAXBException An unexpected problem occurred during validation ValidationException It was detected, that the object is invalid. IllegalArgumentException The parameter was null.

See Also: validateRoot

validateRoot

public boolean validateRoot(Object pObject)

Validates the given JAXB object, but not its child elements.

Parameters: pObject The JAXB object being validated.

Throws: JAXBException An unexpected problem occurred during validation ValidationException It was detected, that the object is invalid. IllegalArgumentException The parameter was null.

See Also: validate