Example usage for javax.xml.bind ValidationEventLocator getOffset

List of usage examples for javax.xml.bind ValidationEventLocator getOffset

Introduction

In this page you can find the example usage for javax.xml.bind ValidationEventLocator getOffset.

Prototype

public int getOffset();

Source Link

Document

Return the byte offset if available

Usage

From source file:org.cloudgraph.config.CloudGraphConfigValidationEventHandler.java

public boolean handleEvent(ValidationEvent ve) {
    boolean result = this.cumulative;
    this.errorCount++;
    ValidationEventLocator vel = ve.getLocator();

    String message = "Line:Col:Offset[" + vel.getLineNumber() + ":" + vel.getColumnNumber() + ":"
            + String.valueOf(vel.getOffset()) + "] - " + ve.getMessage();

    switch (ve.getSeverity()) {
    case ValidationEvent.WARNING:
        log.warn(message);/*from   w w  w  .j  av a2 s . c  om*/
        break;
    case ValidationEvent.ERROR:
    case ValidationEvent.FATAL_ERROR:
        log.fatal(message);
        throw new CloudGraphConfigurationException(message);
    default:
        log.error(message);
    }
    return result;
}

From source file:org.cloudgraph.store.mapping.StoreMappingValidationEventHandler.java

public boolean handleEvent(ValidationEvent ve) {
    boolean result = this.cumulative;
    this.errorCount++;
    ValidationEventLocator vel = ve.getLocator();

    String message = "Line:Col:Offset[" + vel.getLineNumber() + ":" + vel.getColumnNumber() + ":"
            + String.valueOf(vel.getOffset()) + "] - " + ve.getMessage();

    switch (ve.getSeverity()) {
    case ValidationEvent.WARNING:
        log.warn(message);/*from   ww w  .  j av  a2 s.c o  m*/
        break;
    case ValidationEvent.ERROR:
    case ValidationEvent.FATAL_ERROR:
        log.fatal(message);
        throw new StoreMappingException(message);
    default:
        log.error(message);
    }
    return result;
}

From source file:org.modeldriven.fuml.bind.DefaultValidationEventHandler.java

public boolean handleEvent(ValidationEvent ve) {
    boolean result = this.cumulative;
    this.errorCount++;
    ValidationEventLocator vel = ve.getLocator();

    String message = "Line:Col:Offset[" + vel.getLineNumber() + ":" + vel.getColumnNumber() + ":"
            + String.valueOf(vel.getOffset()) + "] - " + ve.getMessage();

    switch (ve.getSeverity()) {
    case ValidationEvent.WARNING:
        log.warn(message);/*from   w w  w.jav  a2 s.c  o  m*/
        break;
    case ValidationEvent.ERROR:
        log.error(message);
        break;
    case ValidationEvent.FATAL_ERROR:
        log.fatal(message);
        break;
    default:
        log.error(message);
    }
    return result;
}

From source file:org.plasma.config.PlasmaConfigValidationEventHandler.java

public boolean handleEvent(ValidationEvent ve) {
    boolean result = this.cumulative;
    this.errorCount++;
    ValidationEventLocator vel = ve.getLocator();

    String message = "Line:Col:Offset[" + vel.getLineNumber() + ":" + vel.getColumnNumber() + ":"
            + String.valueOf(vel.getOffset()) + "] - " + ve.getMessage();

    switch (ve.getSeverity()) {
    case ValidationEvent.WARNING:
        log.warn(message);//ww  w.ja  v a  2 s .c o  m
        break;
    case ValidationEvent.ERROR:
    case ValidationEvent.FATAL_ERROR:
        log.fatal(message);
        throw new ConfigurationException(message);
    default:
        log.error(message);
    }
    return result;
}

From source file:org.plasma.provisioning.cli.XSDTool.java

private static void writeSchemaStagingModel(Model stagingModel, String location, String fileName) {
    try {// ww w  .j  a  v  a  2s . c o  m
        BindingValidationEventHandler debugHandler = new BindingValidationEventHandler() {
            public int getErrorCount() {
                return 0;
            }

            public boolean handleEvent(ValidationEvent ve) {
                ValidationEventLocator vel = ve.getLocator();

                String message = "Line:Col:Offset[" + vel.getLineNumber() + ":" + vel.getColumnNumber() + ":"
                        + String.valueOf(vel.getOffset()) + "] - " + ve.getMessage();

                switch (ve.getSeverity()) {
                default:
                    //log.debug(message);
                }
                return true;
            }
        };
        ProvisioningModelDataBinding binding = new ProvisioningModelDataBinding(debugHandler);
        String xml = binding.marshal(stagingModel);
        binding.validate(xml);

        File provDebugFile = null;
        if (location != null)
            provDebugFile = new File(location, fileName);
        else
            provDebugFile = File.createTempFile(fileName, "");
        FileOutputStream provDebugos = new FileOutputStream(provDebugFile);
        log.debug("Writing provisioning model to: " + provDebugFile.getAbsolutePath());
        binding.marshal(stagingModel, provDebugos);
    } catch (JAXBException e) {
        log.debug(e.getMessage(), e);
    } catch (SAXException e) {
        log.debug(e.getMessage(), e);
    } catch (IOException e) {
        log.debug(e.getMessage(), e);
    }

}

From source file:org.plasma.sdo.helper.PlasmaQueryHelper.java

private void writeStagingModel(Model stagingModel, String location, String fileName) {
    try {/*from  w  w  w  .  ja v  a2 s  .c  o m*/
        BindingValidationEventHandler debugHandler = new BindingValidationEventHandler() {
            public int getErrorCount() {
                return 0;
            }

            public boolean handleEvent(ValidationEvent ve) {
                ValidationEventLocator vel = ve.getLocator();

                String message = "Line:Col:Offset[" + vel.getLineNumber() + ":" + vel.getColumnNumber() + ":"
                        + String.valueOf(vel.getOffset()) + "] - " + ve.getMessage();

                switch (ve.getSeverity()) {
                default:
                    log.debug(message);
                }
                return true;
            }
        };
        ProvisioningModelDataBinding binding = new ProvisioningModelDataBinding(debugHandler);
        String xml = binding.marshal(stagingModel);
        binding.validate(xml);

        File provDebugFile = null;
        if (location != null)
            provDebugFile = new File(location, fileName);
        else
            provDebugFile = File.createTempFile(fileName, "");
        FileOutputStream provDebugos = new FileOutputStream(provDebugFile);
        log.debug("Writing provisioning model to: " + provDebugFile.getAbsolutePath());
        binding.marshal(stagingModel, provDebugos);
    } catch (JAXBException e) {
        log.debug(e.getMessage(), e);
    } catch (SAXException e) {
        log.debug(e.getMessage(), e);
    } catch (IOException e) {
        log.debug(e.getMessage(), e);
    }

}

From source file:org.plasma.sdo.helper.PlasmaXSDHelper.java

private void writeSchemaStagingModel(Model stagingModel, String location, String fileName) {
    try {/*from   w  ww .jav  a  2 s .c  om*/
        BindingValidationEventHandler debugHandler = new BindingValidationEventHandler() {
            public int getErrorCount() {
                return 0;
            }

            public boolean handleEvent(ValidationEvent ve) {
                ValidationEventLocator vel = ve.getLocator();

                String message = "Line:Col:Offset[" + vel.getLineNumber() + ":" + vel.getColumnNumber() + ":"
                        + String.valueOf(vel.getOffset()) + "] - " + ve.getMessage();

                switch (ve.getSeverity()) {
                default:
                    log.debug(message);
                }
                return true;
            }
        };
        ProvisioningModelDataBinding binding = new ProvisioningModelDataBinding(debugHandler);
        String xml = binding.marshal(stagingModel);
        binding.validate(xml);

        File provDebugFile = null;
        if (location != null)
            provDebugFile = new File(location, fileName);
        else
            provDebugFile = File.createTempFile(fileName, "");
        FileOutputStream provDebugos = new FileOutputStream(provDebugFile);
        log.debug("Writing provisioning model to: " + provDebugFile.getAbsolutePath());
        binding.marshal(stagingModel, provDebugos);
    } catch (JAXBException e) {
        log.debug(e.getMessage(), e);
    } catch (SAXException e) {
        log.debug(e.getMessage(), e);
    } catch (IOException e) {
        log.debug(e.getMessage(), e);
    }

}

From source file:org.plasma.xml.uml.DefaultUMLModelAssembler.java

private Document buildDocumentModel(Query query, String destNamespaceURI, String destNamespacePrefix) {
    ProvisioningModelAssembler stagingAssembler = new ProvisioningModelAssembler(query, destNamespaceURI,
            destNamespacePrefix);//from  w  w w.j a  v  a 2  s.c  om
    Model model = stagingAssembler.getModel();

    if (log.isDebugEnabled()) {
        try {
            BindingValidationEventHandler debugHandler = new BindingValidationEventHandler() {
                public int getErrorCount() {
                    return 0;
                }

                public boolean handleEvent(ValidationEvent ve) {
                    ValidationEventLocator vel = ve.getLocator();

                    String message = "Line:Col:Offset[" + vel.getLineNumber() + ":" + vel.getColumnNumber()
                            + ":" + String.valueOf(vel.getOffset()) + "] - " + ve.getMessage();
                    String sev = "";
                    switch (ve.getSeverity()) {
                    case ValidationEvent.WARNING:
                        sev = "WARNING";
                        break;
                    case ValidationEvent.ERROR:
                        sev = "ERROR";
                        break;
                    case ValidationEvent.FATAL_ERROR:
                        sev = "FATAL_ERROR";
                        break;
                    default:
                    }
                    log.debug(sev + " - " + message);

                    return true;
                }
            };
            ProvisioningModelDataBinding binding = new ProvisioningModelDataBinding(debugHandler);
            String xml = binding.marshal(model);
            binding.validate(xml);
            log.debug(xml);
        } catch (JAXBException e) {
            log.debug(e.getMessage(), e);
        } catch (SAXException e) {
            log.debug(e.getMessage(), e);
        }
    }

    return buildDocumentModel(model, destNamespaceURI, destNamespacePrefix);
}