ValidationEventCollector (Java Platform SE 8 )
Keywords: javax.xml.bind.util.ValidationEventCollector class
Date: 2018-07-01

javax.xml.bind.util

## Class ValidationEventCollector

- java.lang.Object
- - javax.xml.bind.util.ValidationEventCollector

- All Implemented Interfaces:
    ValidationEventHandler

      public class ValidationEventCollector
      extends Object
      implements 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.

  Since:
    JAXB1.0
  See Also:
    `Validator`, `ValidationEventHandler`, `ValidationEvent`, `ValidationEventLocator`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ValidationEventCollector()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ValidationEvent[]` | `getEvents()` Return an array of ValidationEvent objects containing a copy of each of the collected errors and warnings.
    `boolean` | `handleEvent(ValidationEvent event)` Receive notification of a validation warning or error.
    `boolean` | `hasEvents()` Returns true if this event collector contains at least one ValidationEvent.
    `void` | `reset()` Clear all collected errors and warnings.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ValidationEventCollector

          public ValidationEventCollector()

  - ### Method Detail

    - #### getEvents

          public ValidationEvent[] getEvents()

      Return an array of ValidationEvent objects containing a copy of each of the collected errors and warnings.
      Returns:
        a copy of all the collected errors and warnings or an empty array if there weren't any

    - #### reset

          public void reset()

      Clear all collected errors and warnings.

    - #### hasEvents

          public boolean hasEvents()

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

    - #### handleEvent

          public boolean handleEvent(ValidationEvent event)

      Description copied from interface: `ValidationEventHandler`
      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.

      Specified by:
        `handleEvent` in interface `ValidationEventHandler`
      Parameters:
        `event` - the encapsulated validation event information. It is a provider error if this parameter is null.
      Returns:
        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`.

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2018, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.