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


Java XMLStreamException.getNestedException方法代碼示例

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


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

示例1: handleStreamException

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
private static JAXBException handleStreamException(XMLStreamException e) {
    // StAXStreamConnector wraps SAXException to XMLStreamException.
    // XMLStreamException doesn't print its nested stack trace when it prints
    // its stack trace, so if we wrap XMLStreamException in JAXBException,
    // it becomes harder to find out the real problem.
    // So we unwrap them here. But we don't want to unwrap too eagerly, because
    // that could throw away some meaningful exception information.
    Throwable ne = e.getNestedException();
    if(ne instanceof JAXBException) {
        return (JAXBException)ne;
    }
    if(ne instanceof SAXException) {
        return new UnmarshalException(ne);
    }
    return new UnmarshalException(e);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:UnmarshallerImpl.java

示例2: testXMLResolver

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
@Test
public void testXMLResolver() {
    try {
        XMLInputFactory xifactory = XMLInputFactory.newInstance();
        xifactory.setProperty(XMLInputFactory.RESOLVER, new MyStaxResolver());
        File file = new File(getClass().getResource("XMLResolverTest.xml").getFile());
        String systemId = file.toURI().toString();
        InputStream entityxml = new FileInputStream(file);
        XMLStreamReader streamReader = xifactory.createXMLStreamReader(systemId, entityxml);
        while (streamReader.hasNext()) {
            int eventType = streamReader.next();
            if (eventType == XMLStreamConstants.START_ELEMENT) {
                eventType = streamReader.next();
                if (eventType == XMLStreamConstants.CHARACTERS) {
                    String text = streamReader.getText();
                    Assert.assertTrue(text.contains("replace2"));
                }
            }
        }
    } catch (XMLStreamException ex) {

        if (ex.getNestedException() != null) {
            ex.getNestedException().printStackTrace();
        }
        // ex.printStackTrace() ;
    } catch (Exception io) {
        io.printStackTrace();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:30,代碼來源:XMLResolverTest.java


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