Top Description Fields Constructors Methods
org.hibernate.internal.util.xml

public Class BufferedXMLEventReader

extends BaseXMLEventReader
Class Inheritance
Imports
java.util.ArrayList, .LinkedList, .List, .ListIterator, javax.xml.stream.XMLEventReader, .XMLStreamException, javax.xml.stream.events.XMLEvent

Buffers XML events for later re-reading Note, copied from the uPortal project by permission of author. See https://github.com/Jasig/uPortal/blob/master/uportal-war/src/main/java/org/jasig/portal/xml/stream/BufferedXMLEventReader.java
Author
Eric Dalquist

Field Summary

Modifier and TypeField and Description
private ListIterator<XMLEvent>
private final LinkedList<XMLEvent>
private int

Constructor Summary

AccessConstructor and Description
public
BufferedXMLEventReader(XMLEventReader reader)

Create new buffering reader, no buffering is done until mark(int) is called.

public
BufferedXMLEventReader(XMLEventReader reader, int eventLimit)

Create new buffering reader.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

The number of events in the buffer.
bufferSize
()

public void
close()

Overrides javax.xml.stream.util.EventReaderDelegate.close.

Implements javax.xml.stream.XMLEventReader.close.

Frees any resources associated with this Reader.
public List<XMLEvent>

Returns:

A copy of the current buffer
getBuffer
()

public boolean
protected XMLEvent
public void
mark()

Same as calling mark(int) with -1.

public void
mark(int
the maximum number of events to buffer. -1 will buffer all events, 0 will buffer no events.
eventLimit
)

Start buffering events

public XMLEvent
peek()

Overrides javax.xml.stream.util.EventReaderDelegate.peek.

Implements javax.xml.stream.XMLEventReader.peek.

Check the next XMLEvent without reading it from the stream.
public void
remove()

Overrides javax.xml.stream.util.EventReaderDelegate.remove.

Overrides default java.util.Iterator.remove.

If reading from the buffer after a reset() call an IllegalStateException will be thrown.
public void
reset()

Reset the reader to these start of the buffered events.

Inherited from org.hibernate.internal.util.xml.BaseXMLEventReader:
getElementTextgetPreviousEventnextnextEventnextTag

Field Detail

bufferReaderback to summary
private ListIterator<XMLEvent> bufferReader
eventBufferback to summary
private final LinkedList<XMLEvent> eventBuffer
eventLimitback to summary
private int eventLimit

Constructor Detail

BufferedXMLEventReaderback to summary
public BufferedXMLEventReader(XMLEventReader reader)

Create new buffering reader, no buffering is done until mark(int) is called.

BufferedXMLEventReaderback to summary
public BufferedXMLEventReader(XMLEventReader reader, int eventLimit)

Create new buffering reader. Calls mark(int) with the specified event limit

See Also
mark(int)

Method Detail

bufferSizeback to summary
public int bufferSize()
Returns:int

The number of events in the buffer.

closeback to summary
public void close() throws XMLStreamException

Overrides javax.xml.stream.util.EventReaderDelegate.close.

Implements javax.xml.stream.XMLEventReader.close.

Doc from javax.xml.stream.XMLEventReader.close.

Frees any resources associated with this Reader. This method does not close the underlying input source.

Annotations
@Override
Exceptions
XMLStreamException:
if there are errors freeing associated resources
getBufferback to summary
public List<XMLEvent> getBuffer()
Returns:List<XMLEvent>

A copy of the current buffer

hasNextback to summary
public boolean hasNext()

Overrides javax.xml.stream.util.EventReaderDelegate.hasNext.

Implements javax.xml.stream.XMLEventReader.hasNext.

Doc from javax.xml.stream.XMLEventReader.hasNext.

Check if there are more events. Returns true if there are more events and false otherwise.

Returns:boolean

true if the event reader has more events, false otherwise

Annotations
@Override
internalNextEventback to summary
protected XMLEvent internalNextEvent() throws XMLStreamException

Implements abstract org.hibernate.internal.util.xml.BaseXMLEventReader.internalNextEvent.

Doc from org.hibernate.internal.util.xml.BaseXMLEventReader.internalNextEvent.

Subclass's version of nextEvent(), called by next()

Annotations
@Override
markback to summary
public void mark()

Same as calling mark(int) with -1.

markback to summary
public void mark(int eventLimit)

Start buffering events

Parameters
eventLimit:int

the maximum number of events to buffer. -1 will buffer all events, 0 will buffer no events.

peekback to summary
public XMLEvent peek() throws XMLStreamException

Overrides javax.xml.stream.util.EventReaderDelegate.peek.

Implements javax.xml.stream.XMLEventReader.peek.

Doc from javax.xml.stream.XMLEventReader.peek.

Check the next XMLEvent without reading it from the stream. Returns null if the stream is at EOF or has no more XMLEvents. A call to peek() will be equal to the next return of next().

Returns:XMLEvent

the next XMLEvent

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
removeback to summary
public void remove()

Overrides javax.xml.stream.util.EventReaderDelegate.remove.

Overrides default java.util.Iterator.remove.

If reading from the buffer after a reset() call an IllegalStateException will be thrown.

Annotations
@Override
resetback to summary
public void reset()

Reset the reader to these start of the buffered events.