SimpleXMLEventReader implements XMLEventReader { @Override public XMLEvent peek() throws XMLStreamException { if (peekedEvent == null) { if (currentEventType < 0) { peekedEvent = allocate(); } else if (delegate.hasNext()) { delegate.next(); peekedEvent = allocate(); } } return peekedEvent; } SimpleXMLEventReader(XMLStreamReader delegate);  SimpleXMLEventReader(XMLStreamReader delegate, XMLEventAllocator allocator); @Override void close(); @Override String getElementText(); @Override Object getProperty(String name); @Override boolean hasNext(); @Override XMLEvent nextEvent(); @Override Object next(); @Override XMLEvent nextTag(); @Override XMLEvent peek(); @Override void remove();  }
@Test public void testPeek() throws XMLStreamException { XMLEventReader reader = createXmlEventReader("<?xml version=\"1.0\"?><alice david=\"edgar\">bob</alice>"); while (reader.hasNext()) { Assert.assertEquals(reader.peek(), reader.nextEvent()); } }