org.codehaus.xfire.util
Class STAXUtils
java.lang.Object
org.codehaus.xfire.util.STAXUtils
public class STAXUtils
- extends Object
Common StAX utilities.
- Since:
- Oct 26, 2004
- Author:
- Dan Diephouse
Method Summary |
static void |
copy(javax.xml.stream.XMLStreamReader reader,
javax.xml.stream.XMLStreamWriter writer)
Copies the reader to the writer. |
static javax.xml.stream.XMLStreamReader |
createXMLStreamReader(InputStream in,
String encoding,
MessageContext ctx)
|
static javax.xml.stream.XMLStreamReader |
createXMLStreamReader(Reader reader)
|
static javax.xml.stream.XMLStreamReader |
createXMLStreamReader(Reader reader,
MessageContext context)
|
static javax.xml.stream.XMLStreamWriter |
createXMLStreamWriter(OutputStream out,
String encoding,
MessageContext ctx)
|
static javax.xml.stream.XMLInputFactory |
getXMLInputFactory(MessageContext ctx)
|
static javax.xml.stream.XMLOutputFactory |
getXMLOutputFactory(MessageContext ctx)
|
static Document |
read(DocumentBuilder builder,
javax.xml.stream.XMLStreamReader reader,
boolean repairing)
|
static void |
readDocElements(Node parent,
javax.xml.stream.XMLStreamReader reader,
boolean repairing)
|
static boolean |
skipToStartOfElement(DepthXMLStreamReader in)
|
static boolean |
skipToStartOfElement(javax.xml.stream.XMLStreamReader in)
Returns true if currently at the start of an element, otherwise move forwards to the next
element start and return true, otherwise false is returned if the end of the stream is reached. |
static boolean |
toNextElement(DepthXMLStreamReader dr)
|
static void |
writeDocument(Document d,
javax.xml.stream.XMLStreamWriter writer,
boolean repairing)
|
static void |
writeDocument(Document d,
javax.xml.stream.XMLStreamWriter writer,
boolean writeProlog,
boolean repairing)
|
static void |
writeElement(Element e,
javax.xml.stream.XMLStreamWriter writer,
boolean repairing)
Writes an Element to an XMLStreamWriter. |
static void |
writeNode(Node n,
javax.xml.stream.XMLStreamWriter writer,
boolean repairing)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
STAXUtils
public STAXUtils()
skipToStartOfElement
public static boolean skipToStartOfElement(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
- Returns true if currently at the start of an element, otherwise move forwards to the next
element start and return true, otherwise false is returned if the end of the stream is reached.
- Throws:
javax.xml.stream.XMLStreamException
toNextElement
public static boolean toNextElement(DepthXMLStreamReader dr)
skipToStartOfElement
public static boolean skipToStartOfElement(DepthXMLStreamReader in)
throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
copy
public static void copy(javax.xml.stream.XMLStreamReader reader,
javax.xml.stream.XMLStreamWriter writer)
throws javax.xml.stream.XMLStreamException
- Copies the reader to the writer. The start and end document
methods must be handled on the writer manually.
TODO: if the namespace on the reader has been declared previously
to where we are in the stream, this probably won't work.
- Parameters:
reader
- writer
-
- Throws:
javax.xml.stream.XMLStreamException
writeDocument
public static void writeDocument(Document d,
javax.xml.stream.XMLStreamWriter writer,
boolean repairing)
throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
writeDocument
public static void writeDocument(Document d,
javax.xml.stream.XMLStreamWriter writer,
boolean writeProlog,
boolean repairing)
throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
writeElement
public static void writeElement(Element e,
javax.xml.stream.XMLStreamWriter writer,
boolean repairing)
throws javax.xml.stream.XMLStreamException
- Writes an Element to an XMLStreamWriter. The writer must already
have started the doucment (via writeStartDocument()). Also, this probably
won't work with just a fragment of a document. The Element should be
the root element of the document.
- Parameters:
e
- writer
-
- Throws:
javax.xml.stream.XMLStreamException
writeNode
public static void writeNode(Node n,
javax.xml.stream.XMLStreamWriter writer,
boolean repairing)
throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
read
public static Document read(DocumentBuilder builder,
javax.xml.stream.XMLStreamReader reader,
boolean repairing)
throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
readDocElements
public static void readDocElements(Node parent,
javax.xml.stream.XMLStreamReader reader,
boolean repairing)
throws javax.xml.stream.XMLStreamException
- Parameters:
parent
- reader
-
- Throws:
javax.xml.stream.XMLStreamException
createXMLStreamWriter
public static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(OutputStream out,
String encoding,
MessageContext ctx)
- Parameters:
out
- encoding
-
- Returns:
getXMLOutputFactory
public static javax.xml.stream.XMLOutputFactory getXMLOutputFactory(MessageContext ctx)
- Returns:
getXMLInputFactory
public static javax.xml.stream.XMLInputFactory getXMLInputFactory(MessageContext ctx)
- Returns:
createXMLStreamReader
public static javax.xml.stream.XMLStreamReader createXMLStreamReader(InputStream in,
String encoding,
MessageContext ctx)
- Parameters:
in
- encoding
- ctx
-
- Returns:
createXMLStreamReader
public static javax.xml.stream.XMLStreamReader createXMLStreamReader(Reader reader)
createXMLStreamReader
public static javax.xml.stream.XMLStreamReader createXMLStreamReader(Reader reader,
MessageContext context)
- Parameters:
reader
-
- Returns:
Copyright © 2004-2013. All Rights Reserved.