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
}
}
}
}
java类javax.xml.stream.EventFilter的实例源码
Bug6976938Test.java 文件源码
项目:openjdk-jdk10
阅读 24
收藏 0
点赞 0
评论 0
XmlFileRecordReader.java 文件源码
项目:datasource
阅读 22
收藏 0
点赞 0
评论 0
/**
* @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();
}
TestXMLSystemFunctions.java 文件源码
项目:teiid
阅读 24
收藏 0
点赞 0
评论 0
@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"));
}
Bug6976938Test.java 文件源码
项目:openjdk9
阅读 25
收藏 0
点赞 0
评论 0
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
}
}
}
}
I5Writer.java 文件源码
项目:Wikipedia-Corpus-Converter
阅读 24
收藏 0
点赞 0
评论 0
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;
}
StAXFilteredEvent.java 文件源码
项目:OpenJSharp
阅读 27
收藏 0
点赞 0
评论 0
public StAXFilteredEvent(XMLEventReader reader, EventFilter filter) throws XMLStreamException
{
eventReader = reader;
_filter = filter;
}
StAXFilteredEvent.java 文件源码
项目:OpenJSharp
阅读 25
收藏 0
点赞 0
评论 0
public void setFilter(EventFilter filter) {
_filter = filter;
}
EventFilterSupport.java 文件源码
项目:OpenJSharp
阅读 26
收藏 0
点赞 0
评论 0
/** Creates a new instance of EventFilterSupport */
public EventFilterSupport(XMLEventReader eventReader, EventFilter eventFilter) {
setParent(eventReader);
fEventFilter = eventFilter;
}
StAXFilteredEvent.java 文件源码
项目:openjdk-jdk10
阅读 23
收藏 0
点赞 0
评论 0
public StAXFilteredEvent(XMLEventReader reader, EventFilter filter) throws XMLStreamException
{
eventReader = reader;
_filter = filter;
}
StAXFilteredEvent.java 文件源码
项目:openjdk-jdk10
阅读 26
收藏 0
点赞 0
评论 0
public void setFilter(EventFilter filter) {
_filter = filter;
}
EventFilterSupport.java 文件源码
项目:openjdk-jdk10
阅读 26
收藏 0
点赞 0
评论 0
/** Creates a new instance of EventFilterSupport */
public EventFilterSupport(XMLEventReader eventReader, EventFilter eventFilter) {
setParent(eventReader);
fEventFilter = eventFilter;
}
MyInputFactory.java 文件源码
项目:openjdk-jdk10
阅读 23
收藏 0
点赞 0
评论 0
@Override
public XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter) throws XMLStreamException {
throw new UnsupportedOperationException("Not supported yet.");
}
XMLInputFactoryWrapper.java 文件源码
项目:openjdk-jdk10
阅读 27
收藏 0
点赞 0
评论 0
@Override
public XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter)
throws XMLStreamException {
return defaultImpl.createFilteredReader(reader, filter);
}
XMLInputFactoryImpl.java 文件源码
项目:openjdk-jdk10
阅读 20
收藏 0
点赞 0
评论 0
@Override
public XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter)
throws XMLStreamException {
return null;
}
StAXFilteredEvent.java 文件源码
项目:openjdk9
阅读 34
收藏 0
点赞 0
评论 0
public StAXFilteredEvent(XMLEventReader reader, EventFilter filter) throws XMLStreamException
{
eventReader = reader;
_filter = filter;
}
StAXFilteredEvent.java 文件源码
项目:openjdk9
阅读 27
收藏 0
点赞 0
评论 0
public void setFilter(EventFilter filter) {
_filter = filter;
}
EventFilterSupport.java 文件源码
项目:openjdk9
阅读 26
收藏 0
点赞 0
评论 0
/** Creates a new instance of EventFilterSupport */
public EventFilterSupport(XMLEventReader eventReader, EventFilter eventFilter) {
setParent(eventReader);
fEventFilter = eventFilter;
}
MyInputFactory.java 文件源码
项目:openjdk9
阅读 24
收藏 0
点赞 0
评论 0
@Override
public XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter) throws XMLStreamException {
throw new UnsupportedOperationException("Not supported yet.");
}
XMLInputFactoryImpl.java 文件源码
项目:openjdk9
阅读 21
收藏 0
点赞 0
评论 0
@Override
public XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter)
throws XMLStreamException {
return null;
}
StAXFilteredEvent.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 23
收藏 0
点赞 0
评论 0
public StAXFilteredEvent(XMLEventReader reader, EventFilter filter) throws XMLStreamException
{
eventReader = reader;
_filter = filter;
}
StAXFilteredEvent.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 31
收藏 0
点赞 0
评论 0
public void setFilter(EventFilter filter) {
_filter = filter;
}
EventFilterSupport.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 28
收藏 0
点赞 0
评论 0
/** Creates a new instance of EventFilterSupport */
public EventFilterSupport(XMLEventReader eventReader, EventFilter eventFilter) {
setParent(eventReader);
fEventFilter = eventFilter;
}
XMLInputFactoryImpl.java 文件源码
项目:javify
阅读 28
收藏 0
点赞 0
评论 0
public XMLEventReader createFilteredReader(XMLEventReader reader,
EventFilter filter)
throws XMLStreamException
{
return new FilteredEventReader(reader, filter);
}
FilteredEventReader.java 文件源码
项目:javify
阅读 26
收藏 0
点赞 0
评论 0
FilteredEventReader(XMLEventReader reader, EventFilter filter)
{
super(reader);
this.filter = filter;
}
XMLInputFactoryImpl.java 文件源码
项目:jvm-stm
阅读 19
收藏 0
点赞 0
评论 0
public XMLEventReader createFilteredReader(XMLEventReader reader,
EventFilter filter)
throws XMLStreamException
{
return new FilteredEventReader(reader, filter);
}
FilteredEventReader.java 文件源码
项目:jvm-stm
阅读 20
收藏 0
点赞 0
评论 0
FilteredEventReader(XMLEventReader reader, EventFilter filter)
{
super(reader);
this.filter = filter;
}
XMLFilteredEventReader.java 文件源码
项目:service-epitope
阅读 23
收藏 0
点赞 0
评论 0
public XMLFilteredEventReader withFilter(EventFilter filter) {
this.f = filter;
return this;
}
AbstractXMLInputFactory.java 文件源码
项目:jettison
阅读 24
收藏 0
点赞 0
评论 0
public XMLEventReader createFilteredReader(XMLEventReader arg0, EventFilter arg1) throws XMLStreamException {
// TODO Auto-generated method stub
return null;
}
StAXFilteredEvent.java 文件源码
项目:infobip-open-jdk-8
阅读 48
收藏 0
点赞 0
评论 0
public StAXFilteredEvent(XMLEventReader reader, EventFilter filter) throws XMLStreamException
{
eventReader = reader;
_filter = filter;
}
StAXFilteredEvent.java 文件源码
项目:infobip-open-jdk-8
阅读 28
收藏 0
点赞 0
评论 0
public void setFilter(EventFilter filter) {
_filter = filter;
}