예제 #1
0
  public void reportError(ValidationEvent ve) throws AbortSerializationException {
    ValidationEventHandler handler;

    try {
      handler = owner.getEventHandler();
    } catch (JAXBException e) {
      throw new AbortSerializationException(e);
    }

    if (!handler.handleEvent(ve)) {
      if (ve.getLinkedException() instanceof Exception)
        throw new AbortSerializationException((Exception) ve.getLinkedException());
      else throw new AbortSerializationException(ve.getMessage());
    }
  }
  public void handleEvent(ValidationEvent event, boolean canRecover) throws SAXException {
    ValidationEventHandler eventHandler;
    try {
      eventHandler = parent.getEventHandler();
    } catch (JAXBException e) {
      // impossible.
      throw new JAXBAssertionError();
    }

    boolean recover = eventHandler.handleEvent(event);

    // if the handler says "abort", we will not return the object
    // from the unmarshaller.getResult()
    if (!recover) aborted = true;

    if (!canRecover || !recover)
      throw new SAXException(
          new UnmarshalException(event.getMessage(), event.getLinkedException()));
  }
예제 #3
0
  public void reportEvent(ValidatableObject source, ValidationEvent event)
      throws AbortSerializationException {
    boolean r;

    try {
      r = eventHandler.handleEvent(event);
    } catch (RuntimeException re) {
      // if the client event handler causes a RuntimeException, then
      // we have to return false.
      r = false;
    }

    if (!r) {
      // throw an exception to abort validation
      throw new AbortSerializationException(event.getMessage());
    }
  }
예제 #4
0
 public boolean handleEvent(ValidationEvent e) {
   hadError = true;
   boolean result;
   if (next != null) {
     // pass it to the application
     try {
       result = next.handleEvent(e);
     } catch (RuntimeException re) {
       // if the client event handler causes a RuntimeException,
       // then we have to return false
       result = false;
     }
   } else {
     // if no error handler was specified, there is no point
     // in continuing the validation.
     result = false;
   }
   return result;
 }