本文整理汇总了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
}
}
}
}
示例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();
}
示例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"));
}
示例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;
}
示例5: StAXFilteredEvent
import javax.xml.stream.EventFilter; //导入依赖的package包/类
public StAXFilteredEvent(XMLEventReader reader, EventFilter filter) throws XMLStreamException
{
eventReader = reader;
_filter = filter;
}
示例6: setFilter
import javax.xml.stream.EventFilter; //导入依赖的package包/类
public void setFilter(EventFilter filter) {
_filter = filter;
}
示例7: EventFilterSupport
import javax.xml.stream.EventFilter; //导入依赖的package包/类
/** Creates a new instance of EventFilterSupport */
public EventFilterSupport(XMLEventReader eventReader, EventFilter eventFilter) {
setParent(eventReader);
fEventFilter = eventFilter;
}
示例8: createFilteredReader
import javax.xml.stream.EventFilter; //导入依赖的package包/类
@Override
public XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter) throws XMLStreamException {
throw new UnsupportedOperationException("Not supported yet.");
}
示例9: createFilteredReader
import javax.xml.stream.EventFilter; //导入依赖的package包/类
@Override
public XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter)
throws XMLStreamException {
return defaultImpl.createFilteredReader(reader, filter);
}
示例10: createFilteredReader
import javax.xml.stream.EventFilter; //导入依赖的package包/类
@Override
public XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter)
throws XMLStreamException {
return null;
}
示例11: createFilteredReader
import javax.xml.stream.EventFilter; //导入依赖的package包/类
public XMLEventReader createFilteredReader(XMLEventReader reader,
EventFilter filter)
throws XMLStreamException
{
return new FilteredEventReader(reader, filter);
}
示例12: FilteredEventReader
import javax.xml.stream.EventFilter; //导入依赖的package包/类
FilteredEventReader(XMLEventReader reader, EventFilter filter)
{
super(reader);
this.filter = filter;
}
示例13: withFilter
import javax.xml.stream.EventFilter; //导入依赖的package包/类
public XMLFilteredEventReader withFilter(EventFilter filter) {
this.f = filter;
return this;
}
示例14: createFilteredReader
import javax.xml.stream.EventFilter; //导入依赖的package包/类
public XMLEventReader createFilteredReader(XMLEventReader arg0, EventFilter arg1) throws XMLStreamException {
// TODO Auto-generated method stub
return null;
}
示例15: createFilteredReader
import javax.xml.stream.EventFilter; //导入依赖的package包/类
@Override
public XMLEventReader createFilteredReader( XMLEventReader reader, EventFilter filter )
throws XMLStreamException
{
return delegate.createFilteredReader( reader, filter );
}