當前位置: 首頁>>代碼示例>>Java>>正文


Java SAXException.initCause方法代碼示例

本文整理匯總了Java中org.xml.sax.SAXException.initCause方法的典型用法代碼示例。如果您正苦於以下問題:Java SAXException.initCause方法的具體用法?Java SAXException.initCause怎麽用?Java SAXException.initCause使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.xml.sax.SAXException的用法示例。


在下文中一共展示了SAXException.initCause方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: log

import org.xml.sax.SAXException; //導入方法依賴的package包/類
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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:StorageReader.java

示例2: endElement

import org.xml.sax.SAXException; //導入方法依賴的package包/類
@Override
public void endElement(String namespaceURI, String localeName,
        String tagName) throws SAXException {
    Command cmd = stack.pop();
    // cmd.setTabCount(tabCount);

    // find if command works in context
    if (!stack.isEmpty()) {
        Command ctx = stack.peek();
        ctx.addChild(cmd);
    }

    // upper level commands
    if (stack.size() == 1 && cmd.isExecutable()) {
        commands.add(cmd);
    }

    // store reference to command
    if (cmd.hasAttr("id")) { //$NON-NLS-1$
        references.put(cmd.getAttr("id"), cmd); //$NON-NLS-1$
    }

    try {
        cmd.exec(references);
    } catch (Exception e) {
        SAXException e2 = new SAXException(e.getMessage());
        
        e2.initCause(e);
        throw e2;
    }

    if (--tabCount < 0) {
        tabCount = 0;
    }

    Command.prn(tabCount, tabCount + ">...<" + tagName + "> end"); //$NON-NLS-1$ //$NON-NLS-2$
}
 
開發者ID:yippeesoft,項目名稱:NotifyTools,代碼行數:38,代碼來源:Handler.java

示例3: startElement

import org.xml.sax.SAXException; //導入方法依賴的package包/類
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;
            maybeAddDefaultConfiguration();
        } 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().getDisplayName());
        } else if ("override".equals(qName) && state == State.DEPS) {
            LOGGER.debug("Ivy.xml dependency overrides are not supported by Gradle. Ignoring override declared in {}", getResource().getDisplayName());
        } 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;
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:72,代碼來源:IvyXmlModuleDescriptorParser.java


注:本文中的org.xml.sax.SAXException.initCause方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。