Java Code Examples for javax.xml.bind.ValidationEvent#getSeverity()

The following examples show how to use javax.xml.bind.ValidationEvent#getSeverity() . 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 Java8CN 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 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: 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 5
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 6
Source File: ValidationEventCollector.java    From openjdk-jdk8u-backup 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 7
Source File: StateGenerator.java    From fix-orchestra with Apache License 2.0 5 votes vote down vote up
@Override
public boolean handleEvent(final ValidationEvent event) {
  errorStream.print(String.format("%s line %d col %d %s", severityToString(event.getSeverity()),
      event.getLocator().getLineNumber(), event.getLocator().getColumnNumber(),
      event.getMessage()));
  return event.getSeverity() == ValidationEvent.WARNING;
}
 
Example 8
Source File: ParsecValidationEventHandler.java    From parsec-libraries with Apache License 2.0 5 votes vote down vote up
@Override
public boolean handleEvent(ValidationEvent event) {
    if (event.getSeverity() > ValidationEvent.WARNING) {
        String message = event.getMessage().replace("\n", " ").trim();
        throw new JaxbException(message);
    }
    return true;
}
 
Example 9
Source File: ValidationExample.java    From jpmml-model with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public boolean handleEvent(ValidationEvent event){
	Level level = (event.getSeverity() == ValidationEvent.WARNING ? Level.WARNING : Level.SEVERE);

	ValidationExample.logger.log(level, String.valueOf(event));

	return true;
}
 
Example 10
Source File: JaxbUtils.java    From govpay with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean handleEvent(ValidationEvent ve) {
	if(ve.getSeverity() == 0) {
		LoggerWrapperFactory.getLogger(JaxbUtils.class).warn("Ricevuto warning di validazione durante il marshalling del messaggio: " + ve.getMessage());
		return true;
	} else {
		return false;
	}
}
 
Example 11
Source File: DocGenerator.java    From fix-orchestra with Apache License 2.0 5 votes vote down vote up
@Override
public boolean handleEvent(final ValidationEvent event) {
  errorStream.print(String.format("%s line %d col %d %s", severityToString(event.getSeverity()),
      event.getLocator().getLineNumber(), event.getLocator().getColumnNumber(),
      event.getMessage()));
  return event.getSeverity() == ValidationEvent.WARNING;
}
 
Example 12
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 13
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 14
Source File: XmlBindingTool.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean handleEvent(ValidationEvent event) {
   String severity;
   boolean continueParsing;
   switch(event.getSeverity()) {
   case 0:
      severity = "Warning";
      continueParsing = true;
      break;
   case 1:
      severity = "Error";
      continueParsing = true;
      break;
   case 2:
      severity = "Fatal error";
      continueParsing = false;
      break;
   default:
      throw new IllegalArgumentException("unknown severity");
   }

   StringBuilder builder = new StringBuilder(severity);
   builder.append(" parsing ");
   builder.append(this.getLocationDescription(event));
   builder.append(" due to ");
   builder.append(event.getMessage());
   this.messages.add(builder.toString());
   return continueParsing;
}
 
Example 15
Source File: XmlBindingTool.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean handleEvent(ValidationEvent event) {
   String severity;
   boolean continueParsing;
   switch(event.getSeverity()) {
   case 0:
      severity = "Warning";
      continueParsing = true;
      break;
   case 1:
      severity = "Error";
      continueParsing = true;
      break;
   case 2:
      severity = "Fatal error";
      continueParsing = false;
      break;
   default:
      throw new IllegalArgumentException("unknown severity");
   }

   StringBuilder builder = new StringBuilder(severity);
   builder.append(" parsing ");
   builder.append(this.getLocationDescription(event));
   builder.append(" due to ");
   builder.append(event.getMessage());
   this.messages.add(builder.toString());
   return continueParsing;
}
 
Example 16
Source File: MyValidationEventHandler.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public boolean handleEvent(ValidationEvent ve) {
	if (ve.getSeverity() == ValidationEvent.FATAL_ERROR ||  ve.getSeverity() == ValidationEvent.ERROR){
		ValidationEventLocator  locator = ve.getLocator();
		//print message from valdation event
		logger.info("Message is {}", ve.getMessage());
		//output line and column number
		logger.info("Column is {} at line number {}", locator.getColumnNumber(), locator.getLineNumber());

		return false;
	}
	return true;
}
 
Example 17
Source File: UnmarshallerImpl.java    From openjdk-jdk8u 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 18
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 19
Source File: UnmarshallerImpl.java    From hottub 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 TencentKona-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;
}