Class WrappedTextNodeStreamReader

java.lang.Object
org.apache.axiom.util.stax.WrappedTextNodeStreamReader
All Implemented Interfaces:
XMLStreamConstants, XMLStreamReader

public class WrappedTextNodeStreamReader extends Object implements XMLStreamReader
XMLStreamReader implementation that represents a text node wrapped inside an element. The text data is provided by a Reader.

It will produce the following sequence of XML events:

  • START_DOCUMENT
  • START_ELEMENT
  • (CHARACTER)*
  • END_ELEMENT
  • END_DOCMENT
The class is implemented as a simple state machine, where the state is identified by the current event type. The initial state is START_DOCUMENT and the following transitions are triggered by next():
  • START_DOCUMENT → START_ELEMENT
  • START_ELEMENT → END_ELEMENT (if character stream is empty)
  • START_ELEMENT → CHARACTERS (if character stream is not empty)
  • CHARACTERS → CHARACTERS (if data available in stream)
  • CHARACTERS → END_ELEMENT (if end of stream reached)
  • END_ELEMENT → END_DOCUMENT
Additionally, getElementText() triggers the following transition:
  • START_ELEMENT → END_ELEMENT
Note that since multiple consecutive CHARACTERS events may be returned, this "parser" is not coalescing.