public class WstxEventReader extends Object implements org.codehaus.stax2.XMLEventReader2, XMLStreamConstants
XMLEventReader2
(and XMLEventReader
).
NOTE: up to Woodstox 5.1, this was based on Stax2 Reference Implementation
(Stax2EventReaderImpl
), but due to various issues
has temporarily (?) been cut-paste-modified here. Ideally it would be reconciled
once Stax2-api version 4.2 can be relied as baseline, but that may take time.
Modifier and Type | Field and Description |
---|---|
protected static int |
ERR_GETELEMTEXT_NON_TEXT_EVENT
Encountered non-textual event (other than closing END_ELEMENT)
when collecting text for getElementText()
|
protected static int |
ERR_GETELEMTEXT_NOT_START_ELEM
Current state when getElementText() called not START_ELEMENT
|
protected static int |
ERR_NEXTTAG_NON_WS_TEXT
Encountered CHARACTERS or CDATA that contains non-white space
char(s), when trying to locate tag with nextTag()
|
protected static int |
ERR_NEXTTAG_WRONG_TYPE
Encountered non-skippable non-text/element event with
nextTag()
|
protected XMLEventAllocator |
mAllocator |
protected boolean |
mCfgMultiDocMode
Marker flag to allow specialized handling in "multi-document" reading
mode.
|
protected XMLEvent |
mPeekedEvent
Event that has been peeked, ie.
|
protected int |
mPrePeekEvent
This variable keeps track of the type of the 'previous' event
when peeking for the next Event.
|
protected org.codehaus.stax2.XMLStreamReader2 |
mReader |
protected int |
mState
High-level state indicator, with currently three values:
whether we are initializing (need to synthetize START_DOCUMENT),
at END_OF_INPUT (end-of-doc), or otherwise, normal operation.
|
protected static int |
STATE_CONTENT |
protected static int |
STATE_END_OF_INPUT |
protected static int |
STATE_INITIAL |
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT
Constructor and Description |
---|
WstxEventReader(XMLEventAllocator a,
org.codehaus.stax2.XMLStreamReader2 r) |
Modifier and Type | Method and Description |
---|---|
protected XMLStreamException |
_checkUnwrap(RuntimeException rex) |
void |
close() |
protected XMLEvent |
createNextEvent(boolean checkEOD,
int type) |
protected XMLEvent |
createStartDocumentEvent()
Method called to create the very first event (START_DOCUMENT).
|
protected String |
findErrorDesc(int errorType,
int currEvent)
Method used to locate error message description to use.
|
String |
getElementText() |
protected String |
getErrorDesc(int errorType,
int currEvent)
Method called upon encountering a problem that should result
in an exception being thrown.
|
Object |
getProperty(String name) |
protected XMLStreamReader |
getStreamReader() |
boolean |
hasNext() |
boolean |
hasNextEvent()
Note: although the interface allows implementations to
throw an
XMLStreamException , the reference implementation
doesn't currently need to. |
boolean |
isPropertySupported(String name) |
Object |
next() |
XMLEvent |
nextEvent() |
XMLEvent |
nextTag() |
XMLEvent |
peek() |
void |
remove()
Note: only here because we implement Iterator interface.
|
protected void |
reportProblem(String msg) |
protected void |
reportProblem(String msg,
Location loc) |
boolean |
setProperty(String name,
Object value) |
protected void |
throwEndOfInput() |
protected void |
throwUnchecked(XMLStreamException sex) |
protected void |
updateStateEndDocument()
Method called when we are about to return
END_DOCUMENT event. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
protected static final int STATE_INITIAL
protected static final int STATE_END_OF_INPUT
protected static final int STATE_CONTENT
protected static final int ERR_GETELEMTEXT_NOT_START_ELEM
protected static final int ERR_GETELEMTEXT_NON_TEXT_EVENT
protected static final int ERR_NEXTTAG_NON_WS_TEXT
protected static final int ERR_NEXTTAG_WRONG_TYPE
protected final XMLEventAllocator mAllocator
protected final org.codehaus.stax2.XMLStreamReader2 mReader
protected XMLEvent mPeekedEvent
nextEvent()
; will be returned and cleared by
call to nextEvent()
(or, returned again if peeked
again)protected int mState
protected int mPrePeekEvent
protected final boolean mCfgMultiDocMode
public WstxEventReader(XMLEventAllocator a, org.codehaus.stax2.XMLStreamReader2 r)
public boolean isPropertySupported(String name)
isPropertySupported
in interface org.codehaus.stax2.XMLEventReader2
public boolean setProperty(String name, Object value)
setProperty
in interface org.codehaus.stax2.XMLEventReader2
protected String getErrorDesc(int errorType, int currEvent)
errorType
- Type of the problem, one of ERR_
constantscurrEvent
- Type of the event that triggered the problem,
if any; -1 if not available.public void close() throws XMLStreamException
close
in interface XMLEventReader
XMLStreamException
public String getElementText() throws XMLStreamException
getElementText
in interface XMLEventReader
XMLStreamException
public Object getProperty(String name)
getProperty
in interface XMLEventReader
public boolean hasNext()
hasNext
in interface Iterator
hasNext
in interface XMLEventReader
public XMLEvent nextEvent() throws XMLStreamException
nextEvent
in interface XMLEventReader
XMLStreamException
public XMLEvent nextTag() throws XMLStreamException
nextTag
in interface XMLEventReader
XMLStreamException
public XMLEvent peek() throws XMLStreamException
peek
in interface XMLEventReader
XMLStreamException
public void remove()
protected void updateStateEndDocument() throws XMLStreamException
END_DOCUMENT
event.
Usually this should change state to STATE_END_OF_INPUT
, but
may vary for some alternative read modes (like multi-document)XMLStreamException
public boolean hasNextEvent() throws XMLStreamException
Note: although the interface allows implementations to
throw an XMLStreamException
, the reference implementation
doesn't currently need to.
It's still declared, in case in future there is need to throw
such an exception.
hasNextEvent
in interface org.codehaus.stax2.XMLEventReader2
XMLStreamException
protected XMLEvent createNextEvent(boolean checkEOD, int type) throws XMLStreamException
XMLStreamException
protected XMLStreamException _checkUnwrap(RuntimeException rex)
protected XMLEvent createStartDocumentEvent() throws XMLStreamException
XMLStreamException
protected void throwEndOfInput()
protected void throwUnchecked(XMLStreamException sex)
protected void reportProblem(String msg) throws XMLStreamException
XMLStreamException
protected void reportProblem(String msg, Location loc) throws XMLStreamException
XMLStreamException
protected XMLStreamReader getStreamReader()
protected final String findErrorDesc(int errorType, int currEvent)
getErrorDesc()
first, and only
if no message found, uses default messages defined here.Copyright © 2019 FasterXML. All rights reserved.