当前位置: 首页>>代码示例>>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;未经允许,请勿转载。