com.atlassian.confluence.content.render.xhtml
Class ResettableXmlEventReader

java.lang.Object
  extended by com.atlassian.confluence.content.render.xhtml.ForwardingXmlEventReader
      extended by com.atlassian.confluence.content.render.xhtml.ResettableXmlEventReader
All Implemented Interfaces:
Iterator, 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
ResettableXmlEventReader(XMLEventReader delegate)
           
 
Method Summary
 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 like nextEvent() or next().
 void restoreEventPosition(int position)
          Moves the pointer of this reader to the specified position.
 
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, toString, wait, wait, wait
 

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 like nextEvent() or next().

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 interface XMLEventReader
Overrides:
nextEvent in class ForwardingXmlEventReader
Throws:
XMLStreamException

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator
Specified by:
hasNext in interface XMLEventReader
Overrides:
hasNext in class ForwardingXmlEventReader

peek

public XMLEvent peek()
              throws XMLStreamException
Specified by:
peek in interface XMLEventReader
Overrides:
peek in class ForwardingXmlEventReader
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 by peek() or nextEvent().

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 via getCurrentEventPosition(). 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 interface XMLEventReader
Overrides:
getElementText in class ForwardingXmlEventReader
Throws:
XMLStreamException

nextTag

public XMLEvent nextTag()
                 throws XMLStreamException
Specified by:
nextTag in interface XMLEventReader
Overrides:
nextTag in class ForwardingXmlEventReader
Throws:
XMLStreamException

next

public Object next()
Specified by:
next in interface Iterator
Overrides:
next in class ForwardingXmlEventReader

remove

public void remove()
Specified by:
remove in interface Iterator
Overrides:
remove in class ForwardingXmlEventReader


Copyright © 2003-2011 Atlassian. All Rights Reserved.