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


Java EventFilter类代码示例

本文整理汇总了Java中javax.xml.stream.EventFilter的典型用法代码示例。如果您正苦于以下问题:Java EventFilter类的具体用法?Java EventFilter怎么用?Java EventFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: eventReaderTest

import javax.xml.stream.EventFilter; //导入依赖的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: initialize

import javax.xml.stream.EventFilter; //导入依赖的package包/类
/**
 * @param dataFile
 * @throws FileNotFoundException
 * @throws XMLStreamException
 * @throws JAXBException
 */
private void initialize(InputStream is) throws FileNotFoundException, XMLStreamException, JAXBException {
	this.is = is;
	ctx = JAXBContext.newInstance(entryClass);
	um = ctx.createUnmarshaller();
	XMLInputFactory xmlif = XMLInputFactory.newInstance();
	xmler = xmlif.createXMLEventReader(is);
	EventFilter filter = new EventFilter() {
		public boolean accept(XMLEvent event) {
			return event.isStartElement();
		}
	};
	xmlfer = xmlif.createFilteredReader(xmler, filter);
	// Jump to the first element in the document, the enclosing Uniprot in
	// the case of uniprot
	// xml
	StartElement e = (StartElement) xmlfer.nextEvent();
	advanceToRecordWithTaxonOfInterest();
}
 
开发者ID:UCDenver-ccp,项目名称:datasource,代码行数:25,代码来源:XmlFileRecordReader.java

示例3: testRepairingNamespaces

import javax.xml.stream.EventFilter; //导入依赖的package包/类
@Test public void testRepairingNamespaces() throws Exception {
	XMLOutputFactory factory = XMLSystemFunctions.getOutputFactory(true);
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	XMLEventWriter writer = factory.createXMLEventWriter(baos);
	XMLEventReader reader = XMLType.getXmlInputFactory().createXMLEventReader(new StringReader("<a xmlns:x=\"http://foo\"><b x:y=\"1\"/></a>"));
	reader.nextTag();
	reader = XMLType.getXmlInputFactory().createFilteredReader(reader, new EventFilter() {
		
		@Override
		public boolean accept(XMLEvent arg0) {
			if (arg0.isStartDocument() || arg0.isEndDocument()) {
				return false;
			}
			if (arg0.isEndElement() && ((EndElement)arg0).getName().getLocalPart().equals("a")) {
				return false;
			}
			return true;
		}
	});
	writer.add(reader);
	writer.close();
	assertEquals("<b xmlns=\"\" xmlns:x=\"http://foo\" x:y=\"1\"></b>", new String(baos.toByteArray(), "UTF-8"));
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:24,代码来源:TestXMLSystemFunctions.java

示例4: createEventFilter

import javax.xml.stream.EventFilter; //导入依赖的package包/类
private EventFilter createEventFilter() {
	EventFilter filter = new EventFilter() {			
		@Override
		public boolean accept(XMLEvent event) {
			if (event.isEndDocument() /*|| event.getEventType() == XMLStreamConstants.DTD*/) return false;
			else return true;
		}
	};
	
	return filter;

}
 
开发者ID:IDS-Mannheim,项目名称:Wikipedia-Corpus-Converter,代码行数:13,代码来源:I5Writer.java

示例5: StAXFilteredEvent

import javax.xml.stream.EventFilter; //导入依赖的package包/类
public StAXFilteredEvent(XMLEventReader reader, EventFilter filter) throws XMLStreamException
{
    eventReader = reader;
    _filter = filter;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:StAXFilteredEvent.java

示例6: setFilter

import javax.xml.stream.EventFilter; //导入依赖的package包/类
public void setFilter(EventFilter filter) {
    _filter = filter;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:StAXFilteredEvent.java

示例7: EventFilterSupport

import javax.xml.stream.EventFilter; //导入依赖的package包/类
/** Creates a new instance of EventFilterSupport */
public EventFilterSupport(XMLEventReader eventReader, EventFilter eventFilter) {
    setParent(eventReader);
    fEventFilter = eventFilter;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:EventFilterSupport.java

示例8: createFilteredReader

import javax.xml.stream.EventFilter; //导入依赖的package包/类
@Override
public XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter) throws XMLStreamException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:MyInputFactory.java

示例9: createFilteredReader

import javax.xml.stream.EventFilter; //导入依赖的package包/类
@Override
public XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter)
        throws XMLStreamException {
    return defaultImpl.createFilteredReader(reader, filter);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:XMLInputFactoryWrapper.java

示例10: createFilteredReader

import javax.xml.stream.EventFilter; //导入依赖的package包/类
@Override
public XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter)
        throws XMLStreamException {
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:XMLInputFactoryImpl.java

示例11: createFilteredReader

import javax.xml.stream.EventFilter; //导入依赖的package包/类
public XMLEventReader createFilteredReader(XMLEventReader reader,
                                           EventFilter filter)
  throws XMLStreamException
{
  return new FilteredEventReader(reader, filter);
}
 
开发者ID:vilie,项目名称:javify,代码行数:7,代码来源:XMLInputFactoryImpl.java

示例12: FilteredEventReader

import javax.xml.stream.EventFilter; //导入依赖的package包/类
FilteredEventReader(XMLEventReader reader, EventFilter filter)
{
  super(reader);
  this.filter = filter;
}
 
开发者ID:vilie,项目名称:javify,代码行数:6,代码来源:FilteredEventReader.java

示例13: withFilter

import javax.xml.stream.EventFilter; //导入依赖的package包/类
public XMLFilteredEventReader withFilter(EventFilter filter) {
    this.f = filter;
    return this;
}
 
开发者ID:nmdp-bioinformatics,项目名称:service-epitope,代码行数:5,代码来源:XMLFilteredEventReader.java

示例14: createFilteredReader

import javax.xml.stream.EventFilter; //导入依赖的package包/类
public XMLEventReader createFilteredReader(XMLEventReader arg0, EventFilter arg1) throws XMLStreamException {
    // TODO Auto-generated method stub
    return null;
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:5,代码来源:AbstractXMLInputFactory.java

示例15: createFilteredReader

import javax.xml.stream.EventFilter; //导入依赖的package包/类
@Override
public XMLEventReader createFilteredReader( XMLEventReader reader, EventFilter filter )
    throws XMLStreamException
{
    return delegate.createFilteredReader( reader, filter );
}
 
开发者ID:werval,项目名称:werval,代码行数:7,代码来源:XMLInputFactoryImpl.java


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