Example usage for javax.xml.bind ValidationEvent ERROR

List of usage examples for javax.xml.bind ValidationEvent ERROR

Introduction

In this page you can find the example usage for javax.xml.bind ValidationEvent ERROR.

Prototype

int ERROR

To view the source code for javax.xml.bind ValidationEvent ERROR.

Click Source Link

Document

Conditions that correspond to the definition of "error" in section 1.2 of the W3C XML 1.0 Recommendation

Usage

From source file:org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil.java

private static void logValidationEvents(URL pluginJarFileUrl, ValidationEventCollector validationEventCollector,
        Log logger) {/*from   w  ww.  j av a2s.  c  om*/
    for (ValidationEvent event : validationEventCollector.getEvents()) {
        // First build the message to be logged. The message will look something like this:
        //
        //   Validation fatal error while parsing [jopr-jboss-as-plugin-4.3.0-SNAPSHOT.jar:META-INF/rhq-plugin.xml]
        //   at line 221, column 94: cvc-minInclusive-valid: Value '20000' is not facet-valid with respect to
        //   minInclusive '30000' for type '#AnonType_defaultIntervalmetric'.
        //
        StringBuilder message = new StringBuilder();
        String severity = null;
        switch (event.getSeverity()) {
        case ValidationEvent.WARNING:
            severity = "warning";
            break;
        case ValidationEvent.ERROR:
            severity = "error";
            break;
        case ValidationEvent.FATAL_ERROR:
            severity = "fatal error";
            break;
        }
        message.append("Validation ").append(severity);
        File pluginJarFile = new File(pluginJarFileUrl.getPath());
        message.append(" while parsing [").append(pluginJarFile.getName()).append(":")
                .append(PLUGIN_DESCRIPTOR_PATH).append("]");
        ValidationEventLocator locator = event.getLocator();
        message.append(" at line ").append(locator.getLineNumber());
        message.append(", column ").append(locator.getColumnNumber());
        message.append(": ").append(event.getMessage());

        // Now write the message to the log at an appropriate level.
        switch (event.getSeverity()) {
        case ValidationEvent.WARNING:
        case ValidationEvent.ERROR:
            logger.warn(message);
            break;
        case ValidationEvent.FATAL_ERROR:
            logger.error(message);
            break;
        }
    }
}

From source file:org.rhq.enterprise.server.xmlschema.ServerPluginDescriptorUtil.java

private static void logValidationEvents(URL pluginJarFileUrl,
        ValidationEventCollector validationEventCollector) {
    for (ValidationEvent event : validationEventCollector.getEvents()) {
        // First build the message to be logged. The message will look something like this:
        ///*  w  ww .ja va  2 s . com*/
        //   Validation fatal error while parsing [jopr-jboss-as-plugin-4.3.0-SNAPSHOT.jar:META-INF/rhq-plugin.xml]
        //   at line 221, column 94: cvc-minInclusive-valid: Value '20000' is not facet-valid with respect to
        //   minInclusive '30000' for type '#AnonType_defaultIntervalmetric'.
        //
        StringBuilder message = new StringBuilder();
        String severity = null;
        switch (event.getSeverity()) {
        case ValidationEvent.WARNING:
            severity = "warning";
            break;
        case ValidationEvent.ERROR:
            severity = "error";
            break;
        case ValidationEvent.FATAL_ERROR:
            severity = "fatal error";
            break;
        }
        message.append("Validation ").append(severity);
        File pluginJarFile = new File(pluginJarFileUrl.getPath());
        message.append(" while parsing [").append(pluginJarFile.getName()).append(":")
                .append(PLUGIN_DESCRIPTOR_PATH).append("]");
        ValidationEventLocator locator = event.getLocator();
        message.append(" at line ").append(locator.getLineNumber());
        message.append(", column ").append(locator.getColumnNumber());
        message.append(": ").append(event.getMessage());

        // Now write the message to the log at an appropriate level.
        switch (event.getSeverity()) {
        case ValidationEvent.WARNING:
        case ValidationEvent.ERROR:
            LOG.warn(message);
            break;
        case ValidationEvent.FATAL_ERROR:
            LOG.error(message);
            break;
        }
    }
}