public class WstxEventReader extends java.lang.Object implements XMLEventReader2, javax.xml.stream.XMLStreamConstants
XMLEventReader
, built on top of
BasicStreamReader
(using composition).
Since there is not much to optimize at this
level (API and underlying stream reader pretty much define functionality
and optimizations that can be done), implementation is fairly straight
forward, with not many surprises.
Implementation notes: trickiest things to implement are:
Modifier and Type | Field and Description |
---|---|
protected int |
mPrePeekEvent
This variable keeps track of the type of the 'previous' event
when peeking for the next Event.
|
protected int |
mState
High-level state indicator, with currently three values:
whether we are initializing (need to synthetize START_DOCUMENT),
at EOD (end-of-doc), or otherwise, normal operation.
|
protected static int |
STATE_CONTENT |
protected static int |
STATE_EOD |
protected static int |
STATE_INITIAL |
Constructor and Description |
---|
WstxEventReader(javax.xml.stream.util.XMLEventAllocator a,
javax.xml.stream.XMLStreamReader r) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected javax.xml.stream.events.XMLEvent |
createNextEvent(boolean checkEOD,
int type) |
protected javax.xml.stream.events.XMLEvent |
createStartEvent()
Method called to create the very first START_DOCUMENT event.
|
java.lang.String |
getElementText() |
java.lang.Object |
getProperty(java.lang.String name) |
boolean |
hasNext() |
boolean |
hasNextEvent()
Note: although the interface allows implementations to
throw an
XMLStreamException , Woodstox doesn't currently need
to. |
java.lang.Object |
next() |
javax.xml.stream.events.XMLEvent |
nextEvent() |
javax.xml.stream.events.XMLEvent |
nextTag() |
javax.xml.stream.events.XMLEvent |
peek() |
void |
remove()
Note: only here because we implement Iterator interface
|
protected void |
throwFromSex(javax.xml.stream.XMLStreamException sex) |
protected void |
throwParseError(java.lang.String msg) |
protected void |
throwParseError(java.lang.String msg,
javax.xml.stream.Location loc) |
protected static final int STATE_INITIAL
protected static final int STATE_EOD
protected static final int STATE_CONTENT
protected int mState
protected int mPrePeekEvent
public WstxEventReader(javax.xml.stream.util.XMLEventAllocator a, javax.xml.stream.XMLStreamReader r)
public void close() throws javax.xml.stream.XMLStreamException
close
in interface javax.xml.stream.XMLEventReader
javax.xml.stream.XMLStreamException
public java.lang.String getElementText() throws javax.xml.stream.XMLStreamException
getElementText
in interface javax.xml.stream.XMLEventReader
javax.xml.stream.XMLStreamException
public java.lang.Object getProperty(java.lang.String name)
getProperty
in interface javax.xml.stream.XMLEventReader
public boolean hasNext()
hasNext
in interface java.util.Iterator
hasNext
in interface javax.xml.stream.XMLEventReader
public javax.xml.stream.events.XMLEvent nextEvent() throws javax.xml.stream.XMLStreamException
nextEvent
in interface javax.xml.stream.XMLEventReader
javax.xml.stream.XMLStreamException
public java.lang.Object next()
next
in interface java.util.Iterator
public javax.xml.stream.events.XMLEvent nextTag() throws javax.xml.stream.XMLStreamException
nextTag
in interface javax.xml.stream.XMLEventReader
javax.xml.stream.XMLStreamException
public javax.xml.stream.events.XMLEvent peek() throws javax.xml.stream.XMLStreamException
peek
in interface javax.xml.stream.XMLEventReader
javax.xml.stream.XMLStreamException
public void remove()
remove
in interface java.util.Iterator
public boolean hasNextEvent() throws javax.xml.stream.XMLStreamException
Note: although the interface allows implementations to
throw an XMLStreamException
, Woodstox doesn't currently need
to. It's still declared, in case in future there is need to throw
such an exception.
hasNextEvent
in interface XMLEventReader2
javax.xml.stream.XMLStreamException
protected javax.xml.stream.events.XMLEvent createNextEvent(boolean checkEOD, int type) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected javax.xml.stream.events.XMLEvent createStartEvent() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected void throwFromSex(javax.xml.stream.XMLStreamException sex)
protected void throwParseError(java.lang.String msg) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected void throwParseError(java.lang.String msg, javax.xml.stream.Location loc) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException