Java Code Examples for javax.xml.bind.ValidationEventHandler#handleEvent()

The following examples show how to use javax.xml.bind.ValidationEventHandler#handleEvent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMLSerializer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void reportError( ValidationEvent ve ) throws SAXException {
    ValidationEventHandler handler;

    try {
        handler = marshaller.getEventHandler();
    } catch( JAXBException e ) {
        throw new SAXException2(e);
    }

    if(!handler.handleEvent(ve)) {
        if(ve.getLinkedException() instanceof Exception)
            throw new SAXException2((Exception)ve.getLinkedException());
        else
            throw new SAXException2(ve.getMessage());
    }
}
 
Example 2
Source File: IValidationEventHandler.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Create an instance of {@link IValidationEventHandler} that invokes both
 * passed event handlers.
 *
 * @param aFirst
 *        The first event handler. May be <code>null</code>.
 * @param aSecond
 *        The second event handler. May be <code>null</code>.
 * @return Never <code>null</code>.
 * @since 8.6.0
 */
@Nonnull
static IValidationEventHandler and (@Nullable final ValidationEventHandler aFirst,
                                    @Nullable final ValidationEventHandler aSecond)
{
  if (aFirst != null)
  {
    if (aSecond != null)
      return x -> {
        if (!aFirst.handleEvent (x))
        {
          // We should not continue
          return false;
        }
        return aSecond.handleEvent (x);
      };
    return aFirst::handleEvent;
  }

  if (aSecond != null)
    return aSecond::handleEvent;

  return x -> true;
}
 
Example 3
Source File: UnmarshallingContext.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reports an error to the user, and asks if s/he wants
 * to recover. If the canRecover flag is false, regardless
 * of the client instruction, an exception will be thrown.
 *
 * Only if the flag is true and the user wants to recover from an error,
 * the method returns normally.
 *
 * The thrown exception will be catched by the unmarshaller.
 */
public void handleEvent(ValidationEvent event, boolean canRecover ) throws SAXException {
    ValidationEventHandler eventHandler = parent.getEventHandler();

    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 SAXParseException2( event.getMessage(), locator,
            new UnmarshalException(
                event.getMessage(),
                event.getLinkedException() ) );
}
 
Example 4
Source File: XMLSerializer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void reportError( ValidationEvent ve ) throws SAXException {
    ValidationEventHandler handler;

    try {
        handler = marshaller.getEventHandler();
    } catch( JAXBException e ) {
        throw new SAXException2(e);
    }

    if(!handler.handleEvent(ve)) {
        if(ve.getLinkedException() instanceof Exception)
            throw new SAXException2((Exception)ve.getLinkedException());
        else
            throw new SAXException2(ve.getMessage());
    }
}
 
Example 5
Source File: UnmarshallingContext.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reports an error to the user, and asks if s/he wants
 * to recover. If the canRecover flag is false, regardless
 * of the client instruction, an exception will be thrown.
 *
 * Only if the flag is true and the user wants to recover from an error,
 * the method returns normally.
 *
 * The thrown exception will be catched by the unmarshaller.
 */
public void handleEvent(ValidationEvent event, boolean canRecover ) throws SAXException {
    ValidationEventHandler eventHandler = parent.getEventHandler();

    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 SAXParseException2( event.getMessage(), locator,
            new UnmarshalException(
                event.getMessage(),
                event.getLinkedException() ) );
}
 
Example 6
Source File: XMLSerializer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void reportError( ValidationEvent ve ) throws SAXException {
    ValidationEventHandler handler;

    try {
        handler = marshaller.getEventHandler();
    } catch( JAXBException e ) {
        throw new SAXException2(e);
    }

    if(!handler.handleEvent(ve)) {
        if(ve.getLinkedException() instanceof Exception)
            throw new SAXException2((Exception)ve.getLinkedException());
        else
            throw new SAXException2(ve.getMessage());
    }
}
 
Example 7
Source File: UnmarshallingContext.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reports an error to the user, and asks if s/he wants
 * to recover. If the canRecover flag is false, regardless
 * of the client instruction, an exception will be thrown.
 *
 * Only if the flag is true and the user wants to recover from an error,
 * the method returns normally.
 *
 * The thrown exception will be catched by the unmarshaller.
 */
public void handleEvent(ValidationEvent event, boolean canRecover ) throws SAXException {
    ValidationEventHandler eventHandler = parent.getEventHandler();

    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 SAXParseException2( event.getMessage(), locator,
            new UnmarshalException(
                event.getMessage(),
                event.getLinkedException() ) );
}
 
Example 8
Source File: XMLSerializer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void reportError( ValidationEvent ve ) throws SAXException {
    ValidationEventHandler handler;

    try {
        handler = marshaller.getEventHandler();
    } catch( JAXBException e ) {
        throw new SAXException2(e);
    }

    if(!handler.handleEvent(ve)) {
        if(ve.getLinkedException() instanceof Exception)
            throw new SAXException2((Exception)ve.getLinkedException());
        else
            throw new SAXException2(ve.getMessage());
    }
}
 
Example 9
Source File: UnmarshallingContext.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reports an error to the user, and asks if s/he wants
 * to recover. If the canRecover flag is false, regardless
 * of the client instruction, an exception will be thrown.
 *
 * Only if the flag is true and the user wants to recover from an error,
 * the method returns normally.
 *
 * The thrown exception will be catched by the unmarshaller.
 */
public void handleEvent(ValidationEvent event, boolean canRecover ) throws SAXException {
    ValidationEventHandler eventHandler = parent.getEventHandler();

    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 SAXParseException2( event.getMessage(), locator,
            new UnmarshalException(
                event.getMessage(),
                event.getLinkedException() ) );
}
 
Example 10
Source File: XMLSerializer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void reportError( ValidationEvent ve ) throws SAXException {
    ValidationEventHandler handler;

    try {
        handler = marshaller.getEventHandler();
    } catch( JAXBException e ) {
        throw new SAXException2(e);
    }

    if(!handler.handleEvent(ve)) {
        if(ve.getLinkedException() instanceof Exception)
            throw new SAXException2((Exception)ve.getLinkedException());
        else
            throw new SAXException2(ve.getMessage());
    }
}
 
Example 11
Source File: UnmarshallingContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reports an error to the user, and asks if s/he wants
 * to recover. If the canRecover flag is false, regardless
 * of the client instruction, an exception will be thrown.
 *
 * Only if the flag is true and the user wants to recover from an error,
 * the method returns normally.
 *
 * The thrown exception will be catched by the unmarshaller.
 */
public void handleEvent(ValidationEvent event, boolean canRecover ) throws SAXException {
    ValidationEventHandler eventHandler = parent.getEventHandler();

    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 SAXParseException2( event.getMessage(), locator,
            new UnmarshalException(
                event.getMessage(),
                event.getLinkedException() ) );
}
 
Example 12
Source File: XMLSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void reportError( ValidationEvent ve ) throws SAXException {
    ValidationEventHandler handler;

    try {
        handler = marshaller.getEventHandler();
    } catch( JAXBException e ) {
        throw new SAXException2(e);
    }

    if(!handler.handleEvent(ve)) {
        if(ve.getLinkedException() instanceof Exception)
            throw new SAXException2((Exception)ve.getLinkedException());
        else
            throw new SAXException2(ve.getMessage());
    }
}
 
Example 13
Source File: UnmarshallingContext.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reports an error to the user, and asks if s/he wants
 * to recover. If the canRecover flag is false, regardless
 * of the client instruction, an exception will be thrown.
 *
 * Only if the flag is true and the user wants to recover from an error,
 * the method returns normally.
 *
 * The thrown exception will be catched by the unmarshaller.
 */
public void handleEvent(ValidationEvent event, boolean canRecover ) throws SAXException {
    ValidationEventHandler eventHandler = parent.getEventHandler();

    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 SAXParseException2( event.getMessage(), locator,
            new UnmarshalException(
                event.getMessage(),
                event.getLinkedException() ) );
}
 
Example 14
Source File: XMLSerializer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void reportError( ValidationEvent ve ) throws SAXException {
    ValidationEventHandler handler;

    try {
        handler = marshaller.getEventHandler();
    } catch( JAXBException e ) {
        throw new SAXException2(e);
    }

    if(!handler.handleEvent(ve)) {
        if(ve.getLinkedException() instanceof Exception)
            throw new SAXException2((Exception)ve.getLinkedException());
        else
            throw new SAXException2(ve.getMessage());
    }
}
 
Example 15
Source File: UnmarshallingContext.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reports an error to the user, and asks if s/he wants
 * to recover. If the canRecover flag is false, regardless
 * of the client instruction, an exception will be thrown.
 *
 * Only if the flag is true and the user wants to recover from an error,
 * the method returns normally.
 *
 * The thrown exception will be catched by the unmarshaller.
 */
public void handleEvent(ValidationEvent event, boolean canRecover ) throws SAXException {
    ValidationEventHandler eventHandler = parent.getEventHandler();

    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 SAXParseException2( event.getMessage(), locator,
            new UnmarshalException(
                event.getMessage(),
                event.getLinkedException() ) );
}
 
Example 16
Source File: XMLSerializer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void reportError( ValidationEvent ve ) throws SAXException {
    ValidationEventHandler handler;

    try {
        handler = marshaller.getEventHandler();
    } catch( JAXBException e ) {
        throw new SAXException2(e);
    }

    if(!handler.handleEvent(ve)) {
        if(ve.getLinkedException() instanceof Exception)
            throw new SAXException2((Exception)ve.getLinkedException());
        else
            throw new SAXException2(ve.getMessage());
    }
}
 
Example 17
Source File: UnmarshallingContext.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reports an error to the user, and asks if s/he wants
 * to recover. If the canRecover flag is false, regardless
 * of the client instruction, an exception will be thrown.
 *
 * Only if the flag is true and the user wants to recover from an error,
 * the method returns normally.
 *
 * The thrown exception will be catched by the unmarshaller.
 */
public void handleEvent(ValidationEvent event, boolean canRecover ) throws SAXException {
    ValidationEventHandler eventHandler = parent.getEventHandler();

    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 SAXParseException2( event.getMessage(), locator,
            new UnmarshalException(
                event.getMessage(),
                event.getLinkedException() ) );
}