Aded createStaxResult

This commit is contained in:
Arjen Poutsma 2009-01-09 12:37:41 +00:00
parent 8ce1f203ff
commit f2329cf426
1 changed files with 41 additions and 0 deletions

View File

@ -75,6 +75,39 @@ public abstract class StaxUtils {
} }
} }
/**
* Creates a StAX {@link Result} for the given {@link XMLStreamWriter}. Returns a {@link StAXResult} under JAXP 1.4 or
* higher, or a {@link StaxResult} otherwise.
*
* @param streamWriter the StAX stream writer
* @return a result wrapping <code>streamWriter</code>
*/
public static Result createStaxResult(XMLStreamWriter streamWriter) {
if (JaxpVersion.isAtLeastJaxp14()) {
return Jaxp14StaxHandler.createStaxResult(streamWriter);
}
else {
return new StaxResult(streamWriter);
}
}
/**
* Creates a StAX {@link Result} for the given {@link XMLEventWriter}. Returns a {@link StAXResult} under JAXP 1.4 or
* higher, or a {@link StaxResult} otherwise.
*
* @param eventWriter the StAX event writer
* @return a result wrapping <code>streamReader</code>
* @throws XMLStreamException in case of StAX errors
*/
public static Result createStaxResult(XMLEventWriter eventWriter) throws XMLStreamException {
if (JaxpVersion.isAtLeastJaxp14()) {
return Jaxp14StaxHandler.createStaxResult(eventWriter);
}
else {
return new StaxResult(eventWriter);
}
}
/** /**
* Indicates whether the given {@link javax.xml.transform.Source} is a StAX Source. * Indicates whether the given {@link javax.xml.transform.Source} is a StAX Source.
* *
@ -252,6 +285,14 @@ public abstract class StaxUtils {
return new StAXSource(eventReader); return new StAXSource(eventReader);
} }
private static Result createStaxResult(XMLStreamWriter streamWriter) {
return new StAXResult(streamWriter);
}
private static Result createStaxResult(XMLEventWriter eventWriter) {
return new StAXResult(eventWriter);
}
private static boolean isStaxSource(Source source) { private static boolean isStaxSource(Source source) {
return source instanceof StAXSource; return source instanceof StAXSource;
} }