Example usage for org.xml.sax SAXParseException getMessage

List of usage examples for org.xml.sax SAXParseException getMessage

Introduction

In this page you can find the example usage for org.xml.sax SAXParseException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Return a detail message for this exception.

Usage

From source file:org.solenopsis.checkstyle.ConfigurationLoader.java

/**
 * Returns the module configurations from a specified input source.
 * Note that if the source does wrap an open byte or character
 * stream, clients are required to close that stream by themselves
 *
 * @param configSource the input stream to the Checkstyle configuration
 * @param overridePropsResolver overriding properties
 * @param omitIgnoredModules {@code true} if modules with severity
 *            'ignore' should be omitted, {@code false} otherwise
 * @return the check configurations/*from  w ww  .  ja v a2s .c o  m*/
 * @throws CheckstyleException if an error occurs
 */
public static Configuration loadConfiguration(InputSource configSource, PropertyResolver overridePropsResolver,
        boolean omitIgnoredModules) throws CheckstyleException {
    try {
        final ConfigurationLoader loader = new ConfigurationLoader(overridePropsResolver, omitIgnoredModules);
        loader.parseInputSource(configSource);
        return loader.configuration;
    } catch (final SAXParseException ex) {
        final String message = String.format(Locale.ROOT, "%s - %s:%s:%s", UNABLE_TO_PARSE_EXCEPTION_PREFIX,
                ex.getMessage(), ex.getLineNumber(), ex.getColumnNumber());
        throw new CheckstyleException(message, ex);
    } catch (final ParserConfigurationException | IOException | SAXException ex) {
        throw new CheckstyleException(UNABLE_TO_PARSE_EXCEPTION_PREFIX, ex);
    }
}

From source file:org.sonar.plugins.xml.checks.XmlSchemaCheck.java

/**
 * Checks if a certain message has already been raised. Avoids duplicate messages.
 *///ww  w  .  j  ava  2s . c o  m
private boolean containsMessage(SAXException e) {
    if (e instanceof SAXParseException) {
        SAXParseException spe = (SAXParseException) e;
        for (Violation v : getWebSourceCode().getViolations()) {
            if (v.getLineId().equals(spe.getLineNumber()) && v.getMessage().equals(spe.getMessage())) {
                return true;
            }
        }
    }
    return false;
}

From source file:org.squale.squalecommon.util.xml.ParsingHandler.java

/**
 * (non-Javadoc)/*from w  ww  . j a  v a  2s  . com*/
 * 
 * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
 */
public void error(SAXParseException exception) throws SAXException {
    String message = CommonMessages.getString("xml.parsing.error", new Object[] { exception.getMessage() });
    mErrors.append(message);
    mErrors.append('\n');
    mLog.error(message, exception);
}

From source file:org.squale.squalecommon.util.xml.ParsingHandler.java

/**
 * (non-Javadoc)/*  w w w. j  a va 2  s . co  m*/
 * 
 * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
 */
public void fatalError(SAXParseException exception) throws SAXException {
    String message = CommonMessages.getString("xml.parsing.fatal", new Object[] { exception.getMessage() });
    mErrors.append(message);
    mErrors.append('\n');
    mLog.fatal(CommonMessages.getString("xml.parsing.fatal"), exception);
}

From source file:org.toobsframework.servlet.filters.compression.CompressionFilterDAO.java

private Element loadDocument(URL url) {
    Document doc = null;//from ww w.ja v  a2  s.  c om
    try {
        InputSource xmlInp = new InputSource(url.openStream());

        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
        doc = parser.parse(xmlInp);
        Element root = doc.getDocumentElement();
        root.normalize();
        return root;
    } catch (SAXParseException err) {
        log.fatal("CompressionFilterDAO ** Parsing error" + ", line " + err.getLineNumber() + ", uri "
                + err.getSystemId());
        log.fatal("CompressionFilterDAO error: " + err.getMessage());
    } catch (SAXException e) {
        log.fatal("CompressionFilterDAO error: " + e);
    } catch (java.net.MalformedURLException mfx) {
        log.fatal("CompressionFilterDAO error: " + mfx);
    } catch (java.io.IOException e) {
        log.fatal("CompressionFilterDAO error: " + e);
    } catch (Exception pce) {
        log.fatal("CompressionFilterDAO error: " + pce);
    }
    return null;
}

From source file:org.tuckey.web.filters.urlrewrite.ConfHandler.java

public void warning(SAXParseException ex) {
    log.debug("error: " + ex.getMessage());
}

From source file:org.tuckey.web.filters.urlrewrite.ConfHandler.java

public void error(SAXParseException ex) {

    log.debug("error: " + ex.getMessage());
}

From source file:org.tuckey.web.filters.urlrewrite.ConfHandler.java

public void fatalError(SAXParseException ex) throws SAXException {
    log.debug("error: " + ex.getMessage());
}

From source file:org.vulpe.commons.xml.XMLReader.java

public List<XMLAttribute> reader(final String xml) {
    final List<XMLAttribute> attributeList = new ArrayList<XMLAttribute>();
    if (StringUtils.isNotEmpty(xml)) {
        try {/*from ww  w.  j a  va  2  s  . c o m*/
            final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            final DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
            final ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("utf-8"));
            final Document document = docBuilder.parse(bais);
            final Node entity = document.getChildNodes().item(0);
            final NodeList atributos = entity.getChildNodes();
            for (int i = 0; i < atributos.getLength(); i++) {
                final String attribute = atributos.item(i).getNodeName();
                if (!"#text".equals(attribute)) {
                    final String value = getChildTagValue((Element) entity, attribute);
                    attributeList.add(new XMLAttribute(attribute, value));
                }
            }
        } catch (SAXParseException err) {
            LOG.error("** Parsing error" + ", line " + err.getLineNumber() + ", uri " + err.getSystemId());
            LOG.error(" " + err.getMessage());
        } catch (SAXException e) {
            final Exception exception = e.getException();
            LOG.error(((exception == null) ? e.getMessage() : exception.getMessage()));
        } catch (Exception e) {
            LOG.error(e.getMessage());
        }
    }
    return attributeList;
}

From source file:org.webcurator.domain.MockPermissionTemplateDAO.java

public MockPermissionTemplateDAO(String filename) {

    super();//from ww w.java  2 s .  c  o m
    try {
        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
        theFile = docBuilder.parse(new File(filename));

        NodeList permissionNodes = theFile.getElementsByTagName("permission");

        // force a nested load of everything
        // loadPermissionsFromNodeList(permissionNodes);
    } catch (SAXParseException err) {
        log.debug("** Parsing error" + ", line " + err.getLineNumber() + ", uri " + err.getSystemId());
        log.debug(" " + err.getMessage());
    } catch (SAXException se) {
        Exception x = se.getException();
        ((x == null) ? se : x).printStackTrace();
    } catch (Exception e) {
        log.debug(e.getClass().getName() + ": " + e.getMessage());
    }
}