Java Code Examples for javax.xml.bind.ValidationEvent#FATAL_ERROR

The following examples show how to use javax.xml.bind.ValidationEvent#FATAL_ERROR . 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: ValidationEventCollector.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public boolean handleEvent( 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;
}
 
Example 2
Source File: ValidationEventCollector.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public boolean handleEvent( 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;
}
 
Example 3
Source File: ValidationEventCollector.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public boolean handleEvent( 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;
}
 
Example 4
Source File: ValidationEventCollector.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public boolean handleEvent( 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;
}
 
Example 5
Source File: AbstractValidationEventHandler.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Get the error level matching the passed JAXB severity.
 *
 * @param nSeverity
 *        The JAXB severity.
 * @return The matching {@link IErrorLevel}. Never <code>null</code>.
 */
@Nonnull
@OverrideOnDemand
protected IErrorLevel getErrorLevel (final int nSeverity)
{
  switch (nSeverity)
  {
    case ValidationEvent.WARNING:
      return EErrorLevel.WARN;
    case ValidationEvent.ERROR:
      return EErrorLevel.ERROR;
    case ValidationEvent.FATAL_ERROR:
      return EErrorLevel.FATAL_ERROR;
    default:
      if (LOGGER.isWarnEnabled ())
        LOGGER.warn ("Unknown JAXB validation severity: " + nSeverity + "; defaulting to error");
      return EErrorLevel.ERROR;
  }
}
 
Example 6
Source File: ValidationEventCollector.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public boolean handleEvent( 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;
}
 
Example 7
Source File: ValidationEventCollector.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public boolean handleEvent( 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;
}
 
Example 8
Source File: ValidationEventCollector.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public boolean handleEvent( 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;
}
 
Example 9
Source File: ValidationEventImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the severity field of this event.
 *
 * @param _severity Must be one of ValidationEvent.WARNING,
 * ValidationEvent.ERROR, or ValidationEvent.FATAL_ERROR.
 * @throws IllegalArgumentException if an illegal severity field is supplied
 */
public void setSeverity( int _severity ) {

    if( _severity != ValidationEvent.WARNING &&
        _severity != ValidationEvent.ERROR &&
        _severity != ValidationEvent.FATAL_ERROR ) {
            throw new IllegalArgumentException(
                Messages.format( Messages.ILLEGAL_SEVERITY ) );
    }

    this.severity = _severity;
}
 
Example 10
Source File: XmlValidationHandler.java    From OpenEstate-IO with Apache License 2.0 5 votes vote down vote up
/**
 * Receive notification of a validation warning or error.
 *
 * <p>
 * <p>
 * The ValidationEvent will have a
 * {@link javax.xml.bind.ValidationEventLocator} embedded in it that
 * indicates where the error or warning occurred.
 *
 * <p>
 * <p>
 * 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.
 *
 * @param event the encapsulated validation event information. It is a provider error if
 *              this parameter is null.
 * @return 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
 * <tt>UnmarshalException</tt>, <tt>ValidationException</tt>, or
 * <tt>MarshalException</tt>.
 * @throws IllegalArgumentException if the event object is null.
 */
@Override
public boolean handleEvent(ValidationEvent event) {
    if (event == null)
        throw new IllegalArgumentException("No validation event was provided!");

    int line = -1;
    int col = -1;
    if (event.getLocator() != null) {
        line = event.getLocator().getLineNumber();
        col = event.getLocator().getColumnNumber();
    }

    if (ValidationEvent.FATAL_ERROR == event.getSeverity()) {
        LOGGER.warn("fatal validation error");
        if (line > -1 && col > -1) LOGGER.warn("> at line " + line + " / column " + col);
        LOGGER.warn("> " + event.getMessage());
        return false;
    }

    if (ValidationEvent.WARNING == event.getSeverity()) {
        LOGGER.warn("validation warning");
        if (line > -1 && col > -1) LOGGER.warn("> at line " + line + " / column " + col);
        LOGGER.warn("> " + event.getMessage());
    } else {
        LOGGER.warn("validation error");
        if (line > -1 && col > -1) LOGGER.warn("> at line " + line + " / column " + col);
        LOGGER.warn("> " + event.getMessage());
    }

    return true;
}
 
Example 11
Source File: ValidationEventImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the severity field of this event.
 *
 * @param _severity Must be one of ValidationEvent.WARNING,
 * ValidationEvent.ERROR, or ValidationEvent.FATAL_ERROR.
 * @throws IllegalArgumentException if an illegal severity field is supplied
 */
public void setSeverity( int _severity ) {

    if( _severity != ValidationEvent.WARNING &&
        _severity != ValidationEvent.ERROR &&
        _severity != ValidationEvent.FATAL_ERROR ) {
            throw new IllegalArgumentException(
                Messages.format( Messages.ILLEGAL_SEVERITY ) );
    }

    this.severity = _severity;
}
 
Example 12
Source File: ValidationEventImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the severity field of this event.
 *
 * @param _severity Must be one of ValidationEvent.WARNING,
 * ValidationEvent.ERROR, or ValidationEvent.FATAL_ERROR.
 * @throws IllegalArgumentException if an illegal severity field is supplied
 */
public void setSeverity( int _severity ) {

    if( _severity != ValidationEvent.WARNING &&
        _severity != ValidationEvent.ERROR &&
        _severity != ValidationEvent.FATAL_ERROR ) {
            throw new IllegalArgumentException(
                Messages.format( Messages.ILLEGAL_SEVERITY ) );
    }

    this.severity = _severity;
}
 
Example 13
Source File: ValidationEventHandlerImpl.java    From photon with Apache License 2.0 5 votes vote down vote up
/**
 * A getter for ValidationEvent error severity
 * @return a translation of the validation event error severity to IMFErrorLogger's ErrorLevel enumeration
 */
public IMFErrorLogger.IMFErrors.ErrorLevels getValidationEventSeverity(){
    switch(this.validationEventSeverity){
        case ValidationEvent.ERROR:
            return IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL;
        case ValidationEvent.FATAL_ERROR:
            return IMFErrorLogger.IMFErrors.ErrorLevels.FATAL;
        case ValidationEvent.WARNING:
            return IMFErrorLogger.IMFErrors.ErrorLevels.WARNING;
        default:
            return IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL;
    }
}
 
Example 14
Source File: ValidationEventImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the severity field of this event.
 *
 * @param _severity Must be one of ValidationEvent.WARNING,
 * ValidationEvent.ERROR, or ValidationEvent.FATAL_ERROR.
 * @throws IllegalArgumentException if an illegal severity field is supplied
 */
public void setSeverity( int _severity ) {

    if( _severity != ValidationEvent.WARNING &&
        _severity != ValidationEvent.ERROR &&
        _severity != ValidationEvent.FATAL_ERROR ) {
            throw new IllegalArgumentException(
                Messages.format( Messages.ILLEGAL_SEVERITY ) );
    }

    this.severity = _severity;
}
 
Example 15
Source File: ValidationEventImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the severity field of this event.
 *
 * @param _severity Must be one of ValidationEvent.WARNING,
 * ValidationEvent.ERROR, or ValidationEvent.FATAL_ERROR.
 * @throws IllegalArgumentException if an illegal severity field is supplied
 */
public void setSeverity( int _severity ) {

    if( _severity != ValidationEvent.WARNING &&
        _severity != ValidationEvent.ERROR &&
        _severity != ValidationEvent.FATAL_ERROR ) {
            throw new IllegalArgumentException(
                Messages.format( Messages.ILLEGAL_SEVERITY ) );
    }

    this.severity = _severity;
}
 
Example 16
Source File: ValidationEventImpl.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Set the severity field of this event.
 *
 * @param _severity Must be one of ValidationEvent.WARNING,
 * ValidationEvent.ERROR, or ValidationEvent.FATAL_ERROR.
 * @throws IllegalArgumentException if an illegal severity field is supplied
 */
public void setSeverity( int _severity ) {

    if( _severity != ValidationEvent.WARNING &&
        _severity != ValidationEvent.ERROR &&
        _severity != ValidationEvent.FATAL_ERROR ) {
            throw new IllegalArgumentException(
                Messages.format( Messages.ILLEGAL_SEVERITY ) );
    }

    this.severity = _severity;
}
 
Example 17
Source File: ValidationEventImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the severity field of this event.
 *
 * @param _severity Must be one of ValidationEvent.WARNING,
 * ValidationEvent.ERROR, or ValidationEvent.FATAL_ERROR.
 * @throws IllegalArgumentException if an illegal severity field is supplied
 */
public void setSeverity( int _severity ) {

    if( _severity != ValidationEvent.WARNING &&
        _severity != ValidationEvent.ERROR &&
        _severity != ValidationEvent.FATAL_ERROR ) {
            throw new IllegalArgumentException(
                Messages.format( Messages.ILLEGAL_SEVERITY ) );
    }

    this.severity = _severity;
}
 
Example 18
Source File: UnmarshallerImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Default error handling behavior for {@link Unmarshaller}.
 */
public boolean handleEvent(ValidationEvent event) {
    return event.getSeverity()!=ValidationEvent.FATAL_ERROR;
}
 
Example 19
Source File: UnmarshallerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Default error handling behavior for {@link Unmarshaller}.
 */
public boolean handleEvent(ValidationEvent event) {
    return event.getSeverity()!=ValidationEvent.FATAL_ERROR;
}
 
Example 20
Source File: UnmarshallerImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Default error handling behavior for {@link Unmarshaller}.
 */
public boolean handleEvent(ValidationEvent event) {
    return event.getSeverity()!=ValidationEvent.FATAL_ERROR;
}