org.xml.sax.SAXException#initCause ( )源码实例Demo

下面列出了org.xml.sax.SAXException#initCause ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: StorageReader.java
private SAXException log(String errorType, SAXParseException e) {
    Level level;
    String message;
    
    if (file == null) {
        level = Level.FINE;
        message = "XML parser " + errorType;
    } else {
        if (isModuleFile()) { //NOI18N
            level = Level.WARNING; // warnings for module layer supplied files
        } else {
            level = Level.FINE; // user files, can be from previous versions
        }

        message = "XML parser " + errorType + " in file " + file.getPath();
    }
    
    SAXException saxe = new SAXException(message);
    saxe.initCause(e);
    LOG.log(level, message, saxe); //NOI18N
    
    return saxe;
}
 
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    try {
        if (state == State.DESCRIPTION) {
            // make sure we don't interpret any tag while in description tag
            descriptionStarted(qName, attributes);
        } else if ("ivy-module".equals(qName)) {
            ivyModuleStarted(attributes);
        } else if ("info".equals(qName)) {
            infoStarted(attributes);
        } else if (state == State.INFO && "extends".equals(qName)) {
            extendsStarted(attributes);
        } else if (state == State.INFO && "license".equals(qName)) {
            getMd().addLicense(new License(substitute(attributes.getValue("name")), substitute(attributes.getValue("url"))));
        } else if (state == State.INFO && "ivyauthor".equals(qName)) {
            // nothing to do, we don't store this
            return;
        } else if (state == State.INFO && "repository".equals(qName)) {
            // nothing to do, we don't store this
            return;
        } else if (state == State.INFO && "description".equals(qName)) {
            getMd().setHomePage(substitute(attributes.getValue("homepage")));
            state = State.DESCRIPTION;
            buffer = new StringBuffer();
        } else if (state == State.INFO && isOtherNamespace(qName)) {
            buffer = new StringBuffer();
            state = State.EXTRA_INFO;
        } else if ("configurations".equals(qName)) {
            configurationStarted(attributes);
        } else if ("publications".equals(qName)) {
            publicationsStarted(attributes);
        } else if ("dependencies".equals(qName)) {
            dependenciesStarted(attributes);
        } else if ("conflicts".equals(qName)) {
            state = State.CONFLICT;
            checkConfigurations();
        } else if ("artifact".equals(qName)) {
            artifactStarted(qName, attributes);
        } else if ("include".equals(qName) && state == State.DEP) {
            addIncludeRule(qName, attributes);
        } else if ("exclude".equals(qName) && state == State.DEP) {
            addExcludeRule(qName, attributes);
        } else if ("exclude".equals(qName) && state == State.DEPS) {
            state = State.EXCLUDE;
            parseRule(qName, attributes);
            getMd().addExcludeRule((ExcludeRule) confAware);
        } else if ("dependency".equals(qName)) {
            dependencyStarted(attributes);
        } else if ("conf".equals(qName)) {
            confStarted(attributes);
        } else if ("mapped".equals(qName)) {
            dd.addDependencyConfiguration(conf, substitute(attributes.getValue("name")));
        } else if (("conflict".equals(qName) && state == State.DEPS) || "manager".equals(qName) && state == State.CONFLICT) {
            LOGGER.debug("Ivy.xml conflict managers are not supported by Gradle. Ignoring conflict manager declared in {}", getResource().getName());
        } else if ("override".equals(qName) && state == State.DEPS) {
            LOGGER.debug("Ivy.xml dependency overrides are not supported by Gradle. Ignoring override declared in {}", getResource().getName());
        } else if ("include".equals(qName) && state == State.CONF) {
            includeConfStarted(attributes);
        } else if (validate && state != State.EXTRA_INFO && state != State.DESCRIPTION) {
            addError("unknown tag " + qName);
        }
    } catch (Exception ex) {
        if (ex instanceof SAXException) {
            throw (SAXException) ex;
        }
        SAXException sax = new SAXException("Problem occurred while parsing ivy file: "
                + ex.getMessage(), ex);
        sax.initCause(ex);
        throw sax;
    }
}
 
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    try {
        if (state == State.DESCRIPTION) {
            // make sure we don't interpret any tag while in description tag
            descriptionStarted(qName, attributes);
        } else if ("ivy-module".equals(qName)) {
            ivyModuleStarted(attributes);
        } else if ("info".equals(qName)) {
            infoStarted(attributes);
        } else if (state == State.INFO && "extends".equals(qName)) {
            extendsStarted(attributes);
        } else if (state == State.INFO && "license".equals(qName)) {
            getMd().addLicense(new License(substitute(attributes.getValue("name")), substitute(attributes.getValue("url"))));
        } else if (state == State.INFO && "ivyauthor".equals(qName)) {
            // nothing to do, we don't store this
            return;
        } else if (state == State.INFO && "repository".equals(qName)) {
            // nothing to do, we don't store this
            return;
        } else if (state == State.INFO && "description".equals(qName)) {
            getMd().setHomePage(substitute(attributes.getValue("homepage")));
            state = State.DESCRIPTION;
            buffer = new StringBuffer();
        } else if (state == State.INFO && isOtherNamespace(qName)) {
            buffer = new StringBuffer();
            state = State.EXTRA_INFO;
        } else if ("configurations".equals(qName)) {
            configurationStarted(attributes);
        } else if ("publications".equals(qName)) {
            publicationsStarted(attributes);
        } else if ("dependencies".equals(qName)) {
            dependenciesStarted(attributes);
        } else if ("conflicts".equals(qName)) {
            if (!descriptorVersion.startsWith("1.")) {
                DeprecationLogger.nagUserWith("Using conflicts section in ivy.xml is deprecated: please use hints section instead. Ivy file: " + getResource().getName());
            }
            state = State.CONFLICT;
            checkConfigurations();
        } else if ("artifact".equals(qName)) {
            artifactStarted(qName, attributes);
        } else if ("include".equals(qName) && state == State.DEP) {
            addIncludeRule(qName, attributes);
        } else if ("exclude".equals(qName) && state == State.DEP) {
            addExcludeRule(qName, attributes);
        } else if ("exclude".equals(qName) && state == State.DEPS) {
            state = State.EXCLUDE;
            parseRule(qName, attributes);
            getMd().addExcludeRule((ExcludeRule) confAware);
        } else if ("dependency".equals(qName)) {
            dependencyStarted(attributes);
        } else if ("conf".equals(qName)) {
            confStarted(attributes);
        } else if ("mapped".equals(qName)) {
            dd.addDependencyConfiguration(conf, substitute(attributes.getValue("name")));
        } else if (("conflict".equals(qName) && state == State.DEPS) || "manager".equals(qName) && state == State.CONFLICT) {
            LOGGER.debug("Ivy.xml conflict managers are not supported by Gradle. Ignoring conflict manager declared in {}", getResource().getName());
        } else if ("override".equals(qName) && state == State.DEPS) {
            LOGGER.debug("Ivy.xml dependency overrides are not supported by Gradle. Ignoring override declared in {}", getResource().getName());
        } else if ("include".equals(qName) && state == State.CONF) {
            includeConfStarted(attributes);
        } else if (validate && state != State.EXTRA_INFO && state != State.DESCRIPTION) {
            addError("unknown tag " + qName);
        }
    } catch (Exception ex) {
        if (ex instanceof SAXException) {
            throw (SAXException) ex;
        }
        SAXException sax = new SAXException("Problem occurred while parsing ivy file: "
                + ex.getMessage(), ex);
        sax.initCause(ex);
        throw sax;
    }
}
 
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    try {
        if (state == State.DESCRIPTION) {
            // make sure we don't interpret any tag while in description tag
            descriptionStarted(qName, attributes);
        } else if ("ivy-module".equals(qName)) {
            ivyModuleStarted(attributes);
        } else if ("info".equals(qName)) {
            infoStarted(attributes);
        } else if (state == State.INFO && "extends".equals(qName)) {
            extendsStarted(attributes);
        } else if (state == State.INFO && "license".equals(qName)) {
            getMd().addLicense(new License(substitute(attributes.getValue("name")), substitute(attributes.getValue("url"))));
        } else if (state == State.INFO && "ivyauthor".equals(qName)) {
            // nothing to do, we don't store this
            return;
        } else if (state == State.INFO && "repository".equals(qName)) {
            // nothing to do, we don't store this
            return;
        } else if (state == State.INFO && "description".equals(qName)) {
            getMd().setHomePage(substitute(attributes.getValue("homepage")));
            state = State.DESCRIPTION;
            buffer = new StringBuffer();
        } else if (state == State.INFO && isOtherNamespace(qName)) {
            buffer = new StringBuffer();
            state = State.EXTRA_INFO;
        } else if ("configurations".equals(qName)) {
            configurationStarted(attributes);
        } else if ("publications".equals(qName)) {
            publicationsStarted(attributes);
        } else if ("dependencies".equals(qName)) {
            dependenciesStarted(attributes);
        } else if ("conflicts".equals(qName)) {
            state = State.CONFLICT;
            checkConfigurations();
        } else if ("artifact".equals(qName)) {
            artifactStarted(qName, attributes);
        } else if ("include".equals(qName) && state == State.DEP) {
            addIncludeRule(qName, attributes);
        } else if ("exclude".equals(qName) && state == State.DEP) {
            addExcludeRule(qName, attributes);
        } else if ("exclude".equals(qName) && state == State.DEPS) {
            state = State.EXCLUDE;
            parseRule(qName, attributes);
            getMd().addExcludeRule((ExcludeRule) confAware);
        } else if ("dependency".equals(qName)) {
            dependencyStarted(attributes);
        } else if ("conf".equals(qName)) {
            confStarted(attributes);
        } else if ("mapped".equals(qName)) {
            dd.addDependencyConfiguration(conf, substitute(attributes.getValue("name")));
        } else if (("conflict".equals(qName) && state == State.DEPS) || "manager".equals(qName) && state == State.CONFLICT) {
            LOGGER.debug("Ivy.xml conflict managers are not supported by Gradle. Ignoring conflict manager declared in {}", getResource().getName());
        } else if ("override".equals(qName) && state == State.DEPS) {
            LOGGER.debug("Ivy.xml dependency overrides are not supported by Gradle. Ignoring override declared in {}", getResource().getName());
        } else if ("include".equals(qName) && state == State.CONF) {
            includeConfStarted(attributes);
        } else if (validate && state != State.EXTRA_INFO && state != State.DESCRIPTION) {
            addError("unknown tag " + qName);
        }
    } catch (Exception ex) {
        if (ex instanceof SAXException) {
            throw (SAXException) ex;
        }
        SAXException sax = new SAXException("Problem occurred while parsing ivy file: "
                + ex.getMessage(), ex);
        sax.initCause(ex);
        throw sax;
    }
}
 
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    try {
        if (state == State.DESCRIPTION) {
            // make sure we don't interpret any tag while in description tag
            descriptionStarted(qName, attributes);
        } else if ("ivy-module".equals(qName)) {
            ivyModuleStarted(attributes);
        } else if ("info".equals(qName)) {
            infoStarted(attributes);
        } else if (state == State.INFO && "extends".equals(qName)) {
            extendsStarted(attributes);
        } else if (state == State.INFO && "license".equals(qName)) {
            getMd().addLicense(new License(substitute(attributes.getValue("name")), substitute(attributes.getValue("url"))));
        } else if (state == State.INFO && "ivyauthor".equals(qName)) {
            // nothing to do, we don't store this
            return;
        } else if (state == State.INFO && "repository".equals(qName)) {
            // nothing to do, we don't store this
            return;
        } else if (state == State.INFO && "description".equals(qName)) {
            getMd().setHomePage(substitute(attributes.getValue("homepage")));
            state = State.DESCRIPTION;
            buffer = new StringBuffer();
        } else if (state == State.INFO && isOtherNamespace(qName)) {
            buffer = new StringBuffer();
            state = State.EXTRA_INFO;
        } else if ("configurations".equals(qName)) {
            configurationStarted(attributes);
        } else if ("publications".equals(qName)) {
            publicationsStarted(attributes);
        } else if ("dependencies".equals(qName)) {
            dependenciesStarted(attributes);
        } else if ("conflicts".equals(qName)) {
            if (!descriptorVersion.startsWith("1.")) {
                DeprecationLogger.nagUserWith("Using conflicts section in ivy.xml is deprecated: please use hints section instead. Ivy file: " + getResource().getName());
            }
            state = State.CONFLICT;
            checkConfigurations();
        } else if ("artifact".equals(qName)) {
            artifactStarted(qName, attributes);
        } else if ("include".equals(qName) && state == State.DEP) {
            addIncludeRule(qName, attributes);
        } else if ("exclude".equals(qName) && state == State.DEP) {
            addExcludeRule(qName, attributes);
        } else if ("exclude".equals(qName) && state == State.DEPS) {
            state = State.EXCLUDE;
            parseRule(qName, attributes);
            getMd().addExcludeRule((ExcludeRule) confAware);
        } else if ("dependency".equals(qName)) {
            dependencyStarted(attributes);
        } else if ("conf".equals(qName)) {
            confStarted(attributes);
        } else if ("mapped".equals(qName)) {
            dd.addDependencyConfiguration(conf, substitute(attributes.getValue("name")));
        } else if (("conflict".equals(qName) && state == State.DEPS) || "manager".equals(qName) && state == State.CONFLICT) {
            LOGGER.debug("Ivy.xml conflict managers are not supported by Gradle. Ignoring conflict manager declared in {}", getResource().getName());
        } else if ("override".equals(qName) && state == State.DEPS) {
            LOGGER.debug("Ivy.xml dependency overrides are not supported by Gradle. Ignoring override declared in {}", getResource().getName());
        } else if ("include".equals(qName) && state == State.CONF) {
            includeConfStarted(attributes);
        } else if (validate && state != State.EXTRA_INFO && state != State.DESCRIPTION) {
            addError("unknown tag " + qName);
        }
    } catch (Exception ex) {
        if (ex instanceof SAXException) {
            throw (SAXException) ex;
        }
        SAXException sax = new SAXException("Problem occurred while parsing ivy file: "
                + ex.getMessage(), ex);
        sax.initCause(ex);
        throw sax;
    }
}
 
源代码6 项目: uima-uimaj   文件: CASTransportable.java
/**
 * Create a SAXException that wraps the given IOException.
 * The wrapping is done using the standard Java 1.4 mechanism, 
 * so that getCause() will work.  Note that new SAXException(Exception) 
 * does NOT work.
 * @param e an IOException to wrap
 * @return a SAX exception for which <code>getCause()</code> will return <code>e</code>.
 */
public SAXException wrapAsSAXException(IOException e) {
  SAXException saxEx =new SAXException(e.getMessage());
  saxEx.initCause(e);
  return saxEx;
}