ValidationEventCollectorpublic class ValidationEventCollector extends Object implements ValidationEventHandler{@link javax.xml.bind.ValidationEventHandler 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. |
Fields Summary |
---|
private final List | events |
Methods Summary |
---|
private static void | _assert(boolean b, java.lang.String msg)
if( !b ) {
throw new InternalError( msg );
}
| public javax.xml.bind.ValidationEvent[] | getEvents()Return an array of ValidationEvent objects containing a copy of each of
the collected errors and warnings.
return events.toArray(new ValidationEvent[events.size()]);
| public boolean | handleEvent(javax.xml.bind.ValidationEvent event)
events.add(event);
boolean retVal = true;
switch( event.getSeverity() ) {
case ValidationEvent.WARNING:
retVal = true; // continue validation
break;
case ValidationEvent.ERROR:
retVal = true; // continue validation
break;
case ValidationEvent.FATAL_ERROR:
retVal = false; // halt validation
break;
default:
_assert( false,
Messages.format( Messages.UNRECOGNIZED_SEVERITY,
event.getSeverity() ) );
break;
}
return retVal;
| public boolean | hasEvents()Returns true if this event collector contains at least one
ValidationEvent.
return !events.isEmpty();
| public void | reset()Clear all collected errors and warnings.
events.clear();
|
|