当前位置: 首页>>代码示例>>Java>>正文


Java XMLInputFactory.createFilteredReader方法代码示例

本文整理汇总了Java中javax.xml.stream.XMLInputFactory.createFilteredReader方法的典型用法代码示例。如果您正苦于以下问题:Java XMLInputFactory.createFilteredReader方法的具体用法?Java XMLInputFactory.createFilteredReader怎么用?Java XMLInputFactory.createFilteredReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.stream.XMLInputFactory的用法示例。


在下文中一共展示了XMLInputFactory.createFilteredReader方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: eventReaderTest

import javax.xml.stream.XMLInputFactory; //导入方法依赖的package包/类
public void eventReaderTest(XMLInputFactory xif) {
    XMLEventReader eventReader = null;
    try {
        eventReader = xif.createXMLEventReader(this.getClass().getResourceAsStream(INPUT_FILE));
        XMLEventReader filteredEventReader = xif.createFilteredReader(eventReader, new EventFilter() {
            public boolean accept(XMLEvent event) {
                if (!event.isStartElement()) {
                    return false;
                }
                QName elementQName = event.asStartElement().getName();
                if ((elementQName.getLocalPart().equals(ATTACHMENT_NAME.getLocalPart()) || elementQName.getLocalPart().equals("Attachment"))
                        && elementQName.getNamespaceURI().equals(VF_GENERIC_TT_NAMESPACE)) {
                    return true;
                }
                return false;
            }
        });
        if (filteredEventReader.hasNext()) {
            System.out.println("containsAttachments() returns true");
        }
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());

    } finally {
        if (eventReader != null) {
            try {
                eventReader.close();
            } catch (XMLStreamException xse) {
                // Ignored by intention
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:Bug6976938Test.java

示例2: testOne

import javax.xml.stream.XMLInputFactory; //导入方法依赖的package包/类
@Test
public void testOne() {
    try {
        XMLInputFactory factory = XMLInputFactory.newInstance();
        XMLStreamReader reader = factory.createFilteredReader(factory.createXMLStreamReader(new StringReader(XML)), new Filter());
        reader.next();
        reader.hasNext(); // force filter to cache
        Assert.assertTrue(reader.getAttributeLocalName(0) != null);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Unexpected Exception: " + e.getMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:AttributeLocalNameTest.java

示例3: createStreamReader

import javax.xml.stream.XMLInputFactory; //导入方法依赖的package包/类
private XMLStreamReader createStreamReader(HasNextTypeFilter f) {

        try {
            XMLInputFactory factory = XMLInputFactory.newInstance();
            factory = XMLInputFactory.newInstance();
            return factory.createFilteredReader(factory.createXMLStreamReader(this.getClass().getResourceAsStream(INPUT_FILE)), (StreamFilter) f);
        } catch (Exception e) {
            e.printStackTrace();
            Assert.fail("Unexpected Exception: " + e.getMessage());
            return null;
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:HasNextTest.java

示例4: createXmlReader

import javax.xml.stream.XMLInputFactory; //导入方法依赖的package包/类
private static XMLEventReader createXmlReader(int max)
        throws XMLStreamException {
    TestInputStream ts = new TestInputStream(max);
    XMLInputFactory xif = XMLInputFactory.newInstance();
    XMLEventReader reader = xif.createXMLEventReader(ts);
    return xif.createFilteredReader(reader, new TagFilter(max));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:EventFilterSupportTest.java


注:本文中的javax.xml.stream.XMLInputFactory.createFilteredReader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。