SimpleXMLFilteredEventReader extends EventReaderDelegate { @Override public XMLEvent peek() throws XMLStreamException { return hasNext() ? getParent().peek() : null; } SimpleXMLFilteredEventReader(XMLEventReader reader, EventFilter filter); @Override void setParent(XMLEventReader reader); @Override boolean hasNext(); @Override XMLEvent peek(); @Override Object next(); @Override XMLEvent nextEvent(); @Override String getElementText(); @Override XMLEvent nextTag();  }
@Test public void testPeek() throws XMLStreamException { XMLEventReader reader = createXmlEventReader("<?xml version=\"1.0\"?><alice david=\"edgar\">bob</alice>", ACCEPT_ALL); while (reader.hasNext()) { Assert.assertEquals(reader.peek(), reader.nextEvent()); } }