|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.axiom.util.stax.XMLStreamReaderUtils
public class XMLStreamReaderUtils
Contains utility methods to work with XMLStreamReader
objects.
Constructor Summary | |
---|---|
XMLStreamReaderUtils()
|
Method Summary | |
---|---|
static DataHandler |
getDataHandlerFromElement(XMLStreamReader reader)
Get a DataHandler for the binary data encoded in an element. |
static DataHandlerReader |
getDataHandlerReader(XMLStreamReader reader)
Get the DataHandlerReader extension from a given XMLStreamReader . |
static Reader |
getElementTextAsStream(XMLStreamReader reader,
boolean allowNonTextChildren)
Get the text content of the current element as a Reader object. |
static XMLStreamReader |
getOriginalXMLStreamReader(XMLStreamReader parser)
Searches the wrapper and delegate classes to find the original XMLStreamReader . |
static void |
writeTextTo(XMLStreamReader reader,
Writer writer)
Get the character data for the current event from the given reader and write it to the given writer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XMLStreamReaderUtils()
Method Detail |
---|
public static DataHandlerReader getDataHandlerReader(XMLStreamReader reader)
DataHandlerReader
extension from a given XMLStreamReader
.
reader
- the stream for which the method should return the DataHandlerReader
extension
DataHandlerReader
extension, or null
if
the reader doesn't implement the extensionpublic static DataHandler getDataHandlerFromElement(XMLStreamReader reader) throws XMLStreamException
DataHandler
for the binary data encoded in an element. The method supports
base64 encoded character data as well as optimized binary data through the
DataHandlerReader
extension.
Precondition: the reader is on a XMLStreamConstants.START_ELEMENT
Postcondition: the reader is on the corresponding
XMLStreamConstants.END_ELEMENT
reader
- the stream to read the data from
XMLStreamException
public static void writeTextTo(XMLStreamReader reader, Writer writer) throws XMLStreamException, IOException
reader
- the reader to get the character data fromwriter
- the writer to write the character data to
XMLStreamException
- if the underlying XML source is not well-formed
IOException
- if an I/O error occurs when writing the character data
IllegalStateException
- if this state is not a valid text state.CharacterDataReader
public static Reader getElementTextAsStream(XMLStreamReader reader, boolean allowNonTextChildren)
Reader
object.
reader
- The XML stream reader to read the element text from. The reader must be positioned
on a XMLStreamConstants.START_ELEMENT
event.allowNonTextChildren
- If set to true
, non text child nodes are allowed and skipped. If set
to false
only text nodes are allowed and the presence of any other
type of child node will trigger an exception.
XMLStreamConstants.END_ELEMENT
event corresponding to the initial
XMLStreamConstants.START_ELEMENT
event. Calling Reader.close()
on the
returned reader has no effect. Any parser exception will be reported by the reader
using XMLStreamIOException
.
IllegalStateException
- if the XML stream reader is not positioned on a
XMLStreamConstants.START_ELEMENT
eventpublic static XMLStreamReader getOriginalXMLStreamReader(XMLStreamReader parser)
XMLStreamReader
.
This method should only be used when a consumer of Axiom really needs to
access the original stream reader.
parser
- XMLStreamReader used by Axiom
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |