|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.util.xml.StaxUtils
public abstract class StaxUtils
Convenience methods for working with the StAX API.
In particular, methods for using StAX (javax.xml.stream
) in combination with the TrAX API
(javax.xml.transform
), and converting StAX readers/writers into SAX readers/handlers and vice-versa.
Constructor Summary | |
---|---|
StaxUtils()
|
Method Summary | |
---|---|
static ContentHandler |
createContentHandler(XMLEventWriter eventWriter)
Create a SAX ContentHandler that writes events to the given StAX XMLEventWriter . |
static ContentHandler |
createContentHandler(XMLStreamWriter streamWriter)
Create a SAX ContentHandler that writes to the given StAX XMLStreamWriter . |
static Result |
createCustomStaxResult(XMLEventWriter eventWriter)
Create a custom, non-JAXP 1.4 StAX Result for the given XMLEventWriter . |
static Result |
createCustomStaxResult(XMLStreamWriter streamWriter)
Create a custom, non-JAXP 1.4 StAX Result for the given XMLStreamWriter . |
static Source |
createCustomStaxSource(XMLEventReader eventReader)
Create a custom, non-JAXP 1.4 StAX Source for the given XMLEventReader . |
static Source |
createCustomStaxSource(XMLStreamReader streamReader)
Create a custom, non-JAXP 1.4 StAX Source for the given XMLStreamReader . |
static XMLStreamReader |
createEventStreamReader(XMLEventReader eventReader)
Return a XMLStreamReader that reads from a XMLEventReader . |
static XMLStreamWriter |
createEventStreamWriter(XMLEventWriter eventWriter,
XMLEventFactory eventFactory)
Return a XMLStreamWriter that writes to a XMLEventWriter . |
static Result |
createStaxResult(XMLEventWriter eventWriter)
Create a StAX Result for the given XMLEventWriter . |
static Result |
createStaxResult(XMLStreamWriter streamWriter)
Create a StAX Result for the given XMLStreamWriter . |
static Source |
createStaxSource(XMLEventReader eventReader)
Create a StAX Source for the given XMLEventReader . |
static Source |
createStaxSource(XMLStreamReader streamReader)
Create a StAX Source for the given XMLStreamReader . |
static XMLReader |
createXMLReader(XMLEventReader eventReader)
Create a SAX XMLReader that reads from the given StAX XMLEventReader . |
static XMLReader |
createXMLReader(XMLStreamReader streamReader)
Create a SAX XMLReader that reads from the given StAX XMLStreamReader . |
static XMLEventReader |
getXMLEventReader(Source source)
Return the XMLEventReader for the given StAX Source. |
static XMLEventWriter |
getXMLEventWriter(Result result)
Return the XMLEventWriter for the given StAX Result. |
static XMLStreamReader |
getXMLStreamReader(Source source)
Return the XMLStreamReader for the given StAX Source. |
static XMLStreamWriter |
getXMLStreamWriter(Result result)
Return the XMLStreamWriter for the given StAX Result. |
static boolean |
isStaxResult(Result result)
Indicate whether the given Result is a StAX Result. |
static boolean |
isStaxSource(Source source)
Indicate whether the given Source is a StAX Source. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StaxUtils()
Method Detail |
---|
public static Source createCustomStaxSource(XMLStreamReader streamReader)
Source
for the given XMLStreamReader
.
streamReader
- the StAX stream reader
streamReader
public static Source createStaxSource(XMLStreamReader streamReader)
Source
for the given XMLStreamReader
.
If JAXP 1.4 is available, this method returns a StAXSource
; otherwise it returns a
custom StAX Source.
streamReader
- the StAX stream reader
streamReader
createCustomStaxSource(XMLStreamReader)
public static Source createCustomStaxSource(XMLEventReader eventReader)
Source
for the given XMLEventReader
.
eventReader
- the StAX event reader
eventReader
public static Source createStaxSource(XMLEventReader eventReader) throws XMLStreamException
Source
for the given XMLEventReader
.
If JAXP 1.4 is available, this method returns a StAXSource
; otherwise it returns a
custom StAX Source.
eventReader
- the StAX event reader
eventReader
XMLStreamException
- in case of StAX errorscreateCustomStaxSource(XMLEventReader)
public static boolean isStaxSource(Source source)
Source
is a StAX Source.
true
if source
is a custom StAX source or JAXP
1.4 StAXSource
; false
otherwise.public static Result createCustomStaxResult(XMLStreamWriter streamWriter)
Result
for the given XMLStreamWriter
.
streamWriter
- the StAX stream writer
streamWriter
public static Result createStaxResult(XMLStreamWriter streamWriter)
Result
for the given XMLStreamWriter
.
If JAXP 1.4 is available, this method returns a StAXResult
; otherwise it returns a
custom StAX Result.
streamWriter
- the StAX stream writer
streamWriter
createCustomStaxResult(XMLStreamWriter)
public static Result createCustomStaxResult(XMLEventWriter eventWriter)
Result
for the given XMLEventWriter
.
eventWriter
- the StAX event writer
eventWriter
public static Result createStaxResult(XMLEventWriter eventWriter) throws XMLStreamException
Result
for the given XMLEventWriter
.
If JAXP 1.4 is available, this method returns a StAXResult
; otherwise it returns a
custom StAX Result.
eventWriter
- the StAX event writer
streamReader
XMLStreamException
- in case of StAX errorscreateCustomStaxResult(XMLEventWriter)
public static boolean isStaxResult(Result result)
Result
is a StAX Result.
true
if result
is a custom Stax Result or JAXP
1.4 StAXResult
; false
otherwise.public static XMLStreamReader getXMLStreamReader(Source source)
XMLStreamReader
for the given StAX Source.
source
- a custom StAX Source or
JAXP 1.4 StAXSource
XMLStreamReader
IllegalArgumentException
- if source
is neither a custom StAX Source
nor JAXP 1.4 StAXSource
public static XMLEventReader getXMLEventReader(Source source)
XMLEventReader
for the given StAX Source.
source
- a custom StAX Source or
JAXP 1.4 StAXSource
XMLEventReader
IllegalArgumentException
- if source
is neither a custom StAX Source
nor a JAXP 1.4 StAXSource
public static XMLStreamWriter getXMLStreamWriter(Result result)
XMLStreamWriter
for the given StAX Result.
result
- a custom StAX Result or
JAXP 1.4 StAXResult
XMLStreamReader
IllegalArgumentException
- if source
is neither a custom StAX Result
nor a JAXP 1.4 StAXResult
public static XMLEventWriter getXMLEventWriter(Result result)
XMLEventWriter
for the given StAX Result.
result
- a custom StAX Result or
JAXP 1.4 StAXResult
XMLStreamReader
IllegalArgumentException
- if source
is neither a custom StAX Result
nor a JAXP 1.4 StAXResult
public static ContentHandler createContentHandler(XMLStreamWriter streamWriter)
ContentHandler
that writes to the given StAX XMLStreamWriter
.
streamWriter
- the StAX stream writer
streamWriter
public static ContentHandler createContentHandler(XMLEventWriter eventWriter)
ContentHandler
that writes events to the given StAX XMLEventWriter
.
eventWriter
- the StAX event writer
eventWriter
public static XMLReader createXMLReader(XMLStreamReader streamReader)
XMLReader
that reads from the given StAX XMLStreamReader
.
streamReader
- the StAX stream reader
streamWriter
public static XMLReader createXMLReader(XMLEventReader eventReader)
XMLReader
that reads from the given StAX XMLEventReader
.
eventReader
- the StAX event reader
eventWriter
public static XMLStreamReader createEventStreamReader(XMLEventReader eventReader) throws XMLStreamException
XMLStreamReader
that reads from a XMLEventReader
. Useful, because the StAX
XMLInputFactory
allows one to create a event reader from a stream reader, but not vice-versa.
XMLStreamException
public static XMLStreamWriter createEventStreamWriter(XMLEventWriter eventWriter, XMLEventFactory eventFactory)
XMLStreamWriter
that writes to a XMLEventWriter
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |