javax.xml.bind
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
{@link javax.xml.bind.ValidationEventHandler} and he may
receive information on the problems location (via the
event handlers {@link javax.xml.bind.ValidationEventLocator}.
A Validator may be present implicitly, invoked by the Unmarshaller. See {@link javax.xml.bind.Unmarshaller#setValidating(boolean)} for more information on that.
Since: JAXB1.0
See Also: ValidationEventHandler ValidationEvent
Method Summary | |
---|---|
ValidationEventHandler | getEventHandler() Returns an event handler that shall be invoked for
notifications on problems detected by the |
Object | getProperty(String pName) Returns the marshallers property Note: The values type depends on the property name. |
void | setEventHandler(ValidationEventHandler pHandler) Registers an event handler that shall be invoked for
notifications on problems detected by the |
void | setProperty(String pName, Object pValue) Sets the Note: The values type depends on the property name. |
boolean | validate(Object pObject) Validates the given JAXB object, invoking its error handler for any problems it detects. |
boolean | validateRoot(Object pObject) Validates the given JAXB object, but not its child elements. |
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.
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.
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.
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.
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 {@link ValidationEventHandler#handleEvent(ValidationEvent)} 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
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