Class ResettableXmlEventReader
- java.lang.Object
-
- com.atlassian.confluence.content.render.xhtml.ForwardingXmlEventReader
-
- com.atlassian.confluence.content.render.xhtml.ResettableXmlEventReader
-
- All Implemented Interfaces:
Iterator<Object>
,XMLEventReader
public class ResettableXmlEventReader extends ForwardingXmlEventReader
Not thread-safe. Ensure each instance of this is restricted to being used in one thread only.
-
-
Field Summary
-
Fields inherited from class com.atlassian.confluence.content.render.xhtml.ForwardingXmlEventReader
delegate
-
-
Constructor Summary
Constructors Constructor Description ResettableXmlEventReader(XMLEventReader delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getCurrentEventPosition()
Returns an integer which represents the position of the current event in the event stream.String
getElementText()
boolean
hasNext()
Object
next()
XMLEvent
nextEvent()
XMLEvent
nextTag()
XMLEvent
peek()
void
remove()
ResettableXmlEventReader
reset()
Resets this reader back to its original state before any events have been consumed through methods likenextEvent()
ornext()
.void
restoreEventPosition(int position)
Moves the pointer of this reader to the specified position.String
toString()
-
Methods inherited from class com.atlassian.confluence.content.render.xhtml.ForwardingXmlEventReader
close, getProperty
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
ResettableXmlEventReader
public ResettableXmlEventReader(XMLEventReader delegate)
-
-
Method Detail
-
reset
public ResettableXmlEventReader reset()
Resets this reader back to its original state before any events have been consumed through methods likenextEvent()
ornext()
.- Returns:
- the current instance of the xml event reader with event position restored to the start (i.e. 0).
-
nextEvent
public XMLEvent nextEvent() throws XMLStreamException
- Specified by:
nextEvent
in interfaceXMLEventReader
- Overrides:
nextEvent
in classForwardingXmlEventReader
- Throws:
XMLStreamException
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfaceIterator<Object>
- Specified by:
hasNext
in interfaceXMLEventReader
- Overrides:
hasNext
in classForwardingXmlEventReader
-
peek
public XMLEvent peek() throws XMLStreamException
- Specified by:
peek
in interfaceXMLEventReader
- Overrides:
peek
in classForwardingXmlEventReader
- Throws:
XMLStreamException
-
getCurrentEventPosition
public int getCurrentEventPosition()
Returns an integer which represents the position of the current event in the event stream. The definition of "current event" is the event that will be served bypeek()
ornextEvent()
.- Returns:
- an integer which represents the position of the current event in the event stream.
-
restoreEventPosition
public void restoreEventPosition(int position)
Moves the pointer of this reader to the specified position. The position specified should be retrieved viagetCurrentEventPosition()
. This method is intended to allow clients to move the pointer back to an earlier position in the stream.Its not meant for fast forwarding - attempting to set a pointer higher than the number of events read from this reader will just result in stream will be served out as per normal.
- Parameters:
position
- an integer representing the position of an event in an event stream- Throws:
IllegalArgumentException
- if pointer is less than zero
-
getElementText
public String getElementText() throws XMLStreamException
- Specified by:
getElementText
in interfaceXMLEventReader
- Overrides:
getElementText
in classForwardingXmlEventReader
- Throws:
XMLStreamException
-
nextTag
public XMLEvent nextTag() throws XMLStreamException
- Specified by:
nextTag
in interfaceXMLEventReader
- Overrides:
nextTag
in classForwardingXmlEventReader
- Throws:
XMLStreamException
-
next
public Object next()
- Specified by:
next
in interfaceIterator<Object>
- Overrides:
next
in classForwardingXmlEventReader
-
remove
public void remove()
- Specified by:
remove
in interfaceIterator<Object>
- Overrides:
remove
in classForwardingXmlEventReader
-
-