|
|||||||||
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.
Nested Class Summary | |
---|---|
private static class |
StaxUtils.Jaxp14StaxHandler
Inner class to avoid a static JAXP 1.4 dependency. |
Field Summary | |
---|---|
private static boolean |
jaxp14Available
|
Constructor Summary | |
---|---|
StaxUtils()
|
Method Summary | |
---|---|
static org.xml.sax.ContentHandler |
createContentHandler(javax.xml.stream.XMLEventWriter eventWriter)
Create a SAX ContentHandler that writes events to the given StAX XMLEventWriter . |
static org.xml.sax.ContentHandler |
createContentHandler(javax.xml.stream.XMLStreamWriter streamWriter)
Create a SAX ContentHandler that writes to the given StAX XMLStreamWriter . |
static javax.xml.transform.Result |
createCustomStaxResult(javax.xml.stream.XMLEventWriter eventWriter)
Create a custom, non-JAXP 1.4 StAX Result for the given XMLEventWriter . |
static javax.xml.transform.Result |
createCustomStaxResult(javax.xml.stream.XMLStreamWriter streamWriter)
Create a custom, non-JAXP 1.4 StAX Result for the given XMLStreamWriter . |
static javax.xml.transform.Source |
createCustomStaxSource(javax.xml.stream.XMLEventReader eventReader)
Create a custom, non-JAXP 1.4 StAX Source for the given XMLEventReader . |
static javax.xml.transform.Source |
createCustomStaxSource(javax.xml.stream.XMLStreamReader streamReader)
Create a custom, non-JAXP 1.4 StAX Source for the given XMLStreamReader . |
static javax.xml.stream.XMLStreamReader |
createEventStreamReader(javax.xml.stream.XMLEventReader eventReader)
Return a XMLStreamReader that reads from a XMLEventReader . |
static javax.xml.stream.XMLStreamWriter |
createEventStreamWriter(javax.xml.stream.XMLEventWriter eventWriter,
javax.xml.stream.XMLEventFactory eventFactory)
Return a XMLStreamWriter that writes to a XMLEventWriter . |
static javax.xml.transform.Result |
createStaxResult(javax.xml.stream.XMLEventWriter eventWriter)
Create a StAX Result for the given XMLEventWriter . |
static javax.xml.transform.Result |
createStaxResult(javax.xml.stream.XMLStreamWriter streamWriter)
Create a StAX Result for the given XMLStreamWriter . |
static javax.xml.transform.Source |
createStaxSource(javax.xml.stream.XMLEventReader eventReader)
Create a StAX Source for the given XMLEventReader . |
static javax.xml.transform.Source |
createStaxSource(javax.xml.stream.XMLStreamReader streamReader)
Create a StAX Source for the given XMLStreamReader . |
static org.xml.sax.XMLReader |
createXMLReader(javax.xml.stream.XMLEventReader eventReader)
Create a SAX XMLReader that reads from the given StAX XMLEventReader . |
static org.xml.sax.XMLReader |
createXMLReader(javax.xml.stream.XMLStreamReader streamReader)
Create a SAX XMLReader that reads from the given StAX XMLStreamReader . |
static javax.xml.stream.XMLEventReader |
getXMLEventReader(javax.xml.transform.Source source)
Return the XMLEventReader for the given StAX Source. |
static javax.xml.stream.XMLEventWriter |
getXMLEventWriter(javax.xml.transform.Result result)
Return the XMLEventWriter for the given StAX Result. |
static javax.xml.stream.XMLStreamReader |
getXMLStreamReader(javax.xml.transform.Source source)
Return the XMLStreamReader for the given StAX Source. |
static javax.xml.stream.XMLStreamWriter |
getXMLStreamWriter(javax.xml.transform.Result result)
Return the XMLStreamWriter for the given StAX Result. |
static boolean |
isStaxResult(javax.xml.transform.Result result)
Indicate whether the given Result is a StAX Result. |
static boolean |
isStaxSource(javax.xml.transform.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 |
Field Detail |
---|
private static boolean jaxp14Available
Constructor Detail |
---|
public StaxUtils()
Method Detail |
---|
public static javax.xml.transform.Source createCustomStaxSource(javax.xml.stream.XMLStreamReader streamReader)
Source
for the given XMLStreamReader
.
streamReader
- the StAX stream reader
streamReader
public static javax.xml.transform.Source createStaxSource(javax.xml.stream.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 javax.xml.transform.Source createCustomStaxSource(javax.xml.stream.XMLEventReader eventReader)
Source
for the given XMLEventReader
.
eventReader
- the StAX event reader
eventReader
public static javax.xml.transform.Source createStaxSource(javax.xml.stream.XMLEventReader eventReader) throws javax.xml.stream.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
javax.xml.stream.XMLStreamException
- in case of StAX errorscreateCustomStaxSource(XMLEventReader)
public static boolean isStaxSource(javax.xml.transform.Source source)
Source
is a StAX Source.
true
if source
is a custom StAX source or JAXP
1.4 StAXSource
; false
otherwise.public static javax.xml.transform.Result createCustomStaxResult(javax.xml.stream.XMLStreamWriter streamWriter)
Result
for the given XMLStreamWriter
.
streamWriter
- the StAX stream writer
streamWriter
public static javax.xml.transform.Result createStaxResult(javax.xml.stream.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 javax.xml.transform.Result createCustomStaxResult(javax.xml.stream.XMLEventWriter eventWriter)
Result
for the given XMLEventWriter
.
eventWriter
- the StAX event writer
eventWriter
public static javax.xml.transform.Result createStaxResult(javax.xml.stream.XMLEventWriter eventWriter) throws javax.xml.stream.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
javax.xml.stream.XMLStreamException
- in case of StAX errorscreateCustomStaxResult(XMLEventWriter)
public static boolean isStaxResult(javax.xml.transform.Result result)
Result
is a StAX Result.
true
if result
is a custom Stax Result or JAXP
1.4 StAXResult
; false
otherwise.public static javax.xml.stream.XMLStreamReader getXMLStreamReader(javax.xml.transform.Source source)
XMLStreamReader
for the given StAX Source.
source
- a custom StAX Source or
JAXP 1.4 StAXSource
XMLStreamReader
java.lang.IllegalArgumentException
- if source
is neither a custom StAX Source
nor JAXP 1.4 StAXSource
public static javax.xml.stream.XMLEventReader getXMLEventReader(javax.xml.transform.Source source)
XMLEventReader
for the given StAX Source.
source
- a custom StAX Source or
JAXP 1.4 StAXSource
XMLEventReader
java.lang.IllegalArgumentException
- if source
is neither a custom StAX Source
nor a JAXP 1.4 StAXSource
public static javax.xml.stream.XMLStreamWriter getXMLStreamWriter(javax.xml.transform.Result result)
XMLStreamWriter
for the given StAX Result.
result
- a custom StAX Result or
JAXP 1.4 StAXResult
XMLStreamReader
java.lang.IllegalArgumentException
- if source
is neither a custom StAX Result
nor a JAXP 1.4 StAXResult
public static javax.xml.stream.XMLEventWriter getXMLEventWriter(javax.xml.transform.Result result)
XMLEventWriter
for the given StAX Result.
result
- a custom StAX Result or
JAXP 1.4 StAXResult
XMLStreamReader
java.lang.IllegalArgumentException
- if source
is neither a custom StAX Result
nor a JAXP 1.4 StAXResult
public static org.xml.sax.ContentHandler createContentHandler(javax.xml.stream.XMLStreamWriter streamWriter)
ContentHandler
that writes to the given StAX XMLStreamWriter
.
streamWriter
- the StAX stream writer
streamWriter
public static org.xml.sax.ContentHandler createContentHandler(javax.xml.stream.XMLEventWriter eventWriter)
ContentHandler
that writes events to the given StAX XMLEventWriter
.
eventWriter
- the StAX event writer
eventWriter
public static org.xml.sax.XMLReader createXMLReader(javax.xml.stream.XMLStreamReader streamReader)
XMLReader
that reads from the given StAX XMLStreamReader
.
streamReader
- the StAX stream reader
streamWriter
public static org.xml.sax.XMLReader createXMLReader(javax.xml.stream.XMLEventReader eventReader)
XMLReader
that reads from the given StAX XMLEventReader
.
eventReader
- the StAX event reader
eventWriter
public static javax.xml.stream.XMLStreamReader createEventStreamReader(javax.xml.stream.XMLEventReader eventReader) throws javax.xml.stream.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.
javax.xml.stream.XMLStreamException
public static javax.xml.stream.XMLStreamWriter createEventStreamWriter(javax.xml.stream.XMLEventWriter eventWriter, javax.xml.stream.XMLEventFactory eventFactory)
XMLStreamWriter
that writes to a XMLEventWriter
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |