Top Description Fields Constructors Methods
javax.xml.bind.util

public Class ValidationEventCollector

extends Object
implements ValidationEventHandler
Class Inheritance
All Implemented Interfaces
javax.xml.bind.ValidationEventHandler
Imports
javax.xml.bind.ValidationEvent, .ValidationEventHandler, java.util.ArrayList, .List

ValidationEventHandler implementation that collects all events.

To use this class, create a new instance and pass it to the setEventHandler method of the Validator, Unmarshaller, Marshaller class. After the call to validate or unmarshal completes, call the getEvents method to retrieve all the reported errors and warnings.

Author
Since
1.6, JAXB 1.0
See Also
javax.xml.bind.Validator, javax.xml.bind.ValidationEventHandler, javax.xml.bind.ValidationEvent, javax.xml.bind.ValidationEventLocator

Field Summary

Modifier and TypeField and Description
private final List<ValidationEvent>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static void
_assert(boolean b, String msg)

public ValidationEvent[]

Returns:

a copy of all the collected errors and warnings or an empty array if there weren't any
getEvents
()

Return an array of ValidationEvent objects containing a copy of each of the collected errors and warnings.

public boolean
handleEvent(ValidationEvent
the encapsulated validation event information. It is a provider error if this parameter is null.
event
)

Implements javax.xml.bind.ValidationEventHandler.handleEvent.

Receive notification of a validation warning or error.
public boolean

Returns:

true if this event collector contains at least one ValidationEvent, false otherwise
hasEvents
()

Returns true if this event collector contains at least one ValidationEvent.

public void
reset()

Clear all collected errors and warnings.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

eventsback to summary
private final List<ValidationEvent> events

Constructor Detail

ValidationEventCollectorback to summary
public ValidationEventCollector()

Method Detail

_assertback to summary
private static void _assert(boolean b, String msg)
getEventsback to summary
public ValidationEvent[] getEvents()

Return an array of ValidationEvent objects containing a copy of each of the collected errors and warnings.

Returns:ValidationEvent[]

a copy of all the collected errors and warnings or an empty array if there weren't any

handleEventback to summary
public boolean handleEvent(ValidationEvent event)

Implements javax.xml.bind.ValidationEventHandler.handleEvent.

Doc from javax.xml.bind.ValidationEventHandler.handleEvent.

Receive notification of a validation warning or error. The ValidationEvent will have a ValidationEventLocator embedded in it that indicates where the error or warning occurred.

If an unchecked runtime exception is thrown from this method, the JAXB provider will treat it as if the method returned false and interrupt the current unmarshal, validate, or marshal operation.

Parameters
event:ValidationEvent

the encapsulated validation event information. It is a provider error if this parameter is null.

Returns:boolean

true if the JAXB Provider should attempt to continue the current unmarshal, validate, or marshal operation after handling this warning/error, false if the provider should terminate the current operation with the appropriate UnmarshalException, ValidationException, or MarshalException.

hasEventsback to summary
public boolean hasEvents()

Returns true if this event collector contains at least one ValidationEvent.

Returns:boolean

true if this event collector contains at least one ValidationEvent, false otherwise

resetback to summary
public void reset()

Clear all collected errors and warnings.