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

The following examples show how to use javax.xml.bind.ValidationEvent#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 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 3
Source File: ValidationEventCollector.java    From openjdk-jdk9 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: ValidationErrorHandler.java    From importer-exporter with Apache License 2.0 6 votes vote down vote up
@Override
public boolean handleEvent(ValidationEvent event) {
    StringBuilder msg = new StringBuilder();
    LogLevel type;

    switch (event.getSeverity()) {
        case ValidationEvent.FATAL_ERROR:
        case ValidationEvent.ERROR:
            msg.append("Invalid content");
            type = LogLevel.ERROR;
            break;
        case ValidationEvent.WARNING:
            msg.append("Warning");
            type = LogLevel.WARN;
            break;
        default:
            return reportAllErrors;
    }

    msg.append(": ").append(event.getMessage());
    log.log(type, msg.toString());

    validationErrors++;
    return reportAllErrors;
}
 
Example 5
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 6
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 7
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 8
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 9
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 10
Source File: Openscoring.java    From openscoring with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public boolean handleEvent(ValidationEvent event){
	int severity = event.getSeverity();

	switch(severity){
		case ValidationEvent.ERROR:
		case ValidationEvent.FATAL_ERROR:
			return false;
		default:
			return true;
	}
}
 
Example 11
Source File: XmlValidationHandler.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean handleEvent(ValidationEvent event) {
	if (event.getSeverity() == ValidationEvent.FATAL_ERROR || event.getSeverity() == ValidationEvent.ERROR) {
		ValidationEventLocator locator = event.getLocator();
		String message = event.getMessage();
		int line = locator.getLineNumber();
		int column = locator.getColumnNumber();
		log.error("Error at [line=" + line + ", column=" + column + "]: " + message);
		throw new Error(event.getLinkedException());
	}
	return true;
}
 
Example 12
Source File: ValidationEventHandlerImpl.java    From web-feature-service with Apache License 2.0 5 votes vote down vote up
@Override
public boolean handleEvent(ValidationEvent event) {
	StringBuilder msg = new StringBuilder();
	LogLevel type = LogLevel.ERROR;

	switch (event.getSeverity()) {
	case ValidationEvent.FATAL_ERROR:
	case ValidationEvent.ERROR:
		msg.append("Invalid XML content");
		type = LogLevel.ERROR;
		isValid = false;
		break;
	case ValidationEvent.WARNING:
		msg.append("Warning");
		type = LogLevel.WARN;
		break;
	}

	if (event.getLocator() != null) {
		msg.append(" at [").append(event.getLocator().getLineNumber())
		.append(", ").append(event.getLocator().getColumnNumber()).append("]");
	}

	msg.append(": ").append(event.getMessage());		
	log.log(type, msg.toString());
	
	if (!isValid)
		cause = msg.toString();
	
	return isValid;
}
 
Example 13
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 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: StateGenerator.java    From fix-orchestra with Apache License 2.0 5 votes vote down vote up
private String severityToString(final int severity) {
  switch (severity) {
    case ValidationEvent.WARNING:
      return "WARN ";
    case ValidationEvent.ERROR:
      return "ERROR";
    default:
      return "FATAL";
  }
}
 
Example 16
Source File: ValidationEventImpl.java    From openjdk-8-source 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 17
Source File: ValidationEventImpl.java    From jdk1.8-source-analysis 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 18
Source File: XMLSerializer.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Report an error found as an exception.
 *
 * @param fieldName
 *      the name of the property being processed when an error is found.
 */
public final void reportError(String fieldName, Throwable t) throws SAXException {
    ValidationEvent ve = new ValidationEventImpl(ValidationEvent.ERROR,
        t.getMessage(), getCurrentLocation(fieldName), t);
    reportError(ve);
}
 
Example 19
Source File: XMLSerializer.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Report an error found as an exception.
 *
 * @param fieldName
 *      the name of the property being processed when an error is found.
 */
public final void reportError(String fieldName, Throwable t) throws SAXException {
    ValidationEvent ve = new ValidationEventImpl(ValidationEvent.ERROR,
        t.getMessage(), getCurrentLocation(fieldName), t);
    reportError(ve);
}
 
Example 20
Source File: XMLSerializer.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Report an error found as an exception.
 *
 * @param fieldName
 *      the name of the property being processed when an error is found.
 */
public final void reportError(String fieldName, Throwable t) throws SAXException {
    ValidationEvent ve = new ValidationEventImpl(ValidationEvent.ERROR,
        t.getMessage(), getCurrentLocation(fieldName), t);
    reportError(ve);
}