org.codehaus.xfire.util
Class STAXUtils

java.lang.Object
  extended by org.codehaus.xfire.util.STAXUtils

public class STAXUtils
extends java.lang.Object

Common StAX utilities.

Since:
Oct 26, 2004
Author:
Dan Diephouse

Constructor Summary
STAXUtils()
           
 
Method Summary
static void copy(XMLStreamReader reader, XMLStreamWriter writer)
          Copies the reader to the writer.
static XMLStreamReader createXMLStreamReader(java.io.InputStream in, java.lang.String encoding, MessageContext ctx)
           
static XMLStreamReader createXMLStreamReader(java.io.Reader reader)
           
static XMLStreamReader createXMLStreamReader(java.io.Reader reader, MessageContext context)
           
static XMLStreamWriter createXMLStreamWriter(java.io.OutputStream out, java.lang.String encoding, MessageContext ctx)
           
static XMLInputFactory getXMLInputFactory(MessageContext ctx)
           
static XMLOutputFactory getXMLOutputFactory(MessageContext ctx)
           
static org.w3c.dom.Document read(javax.xml.parsers.DocumentBuilder builder, XMLStreamReader reader, boolean repairing)
           
static void readDocElements(org.w3c.dom.Node parent, XMLStreamReader reader, boolean repairing)
           
static boolean skipToStartOfElement(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(org.w3c.dom.Document d, XMLStreamWriter writer, boolean repairing)
           
static void writeElement(org.w3c.dom.Element e, XMLStreamWriter writer, boolean repairing)
          Writes an Element to an XMLStreamWriter.
static void writeNode(org.w3c.dom.Node n, XMLStreamWriter writer, boolean repairing)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

STAXUtils

public STAXUtils()
Method Detail

skipToStartOfElement

public static boolean skipToStartOfElement(XMLStreamReader in)
                                    throws 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:
XMLStreamException

toNextElement

public static boolean toNextElement(DepthXMLStreamReader dr)

copy

public static void copy(XMLStreamReader reader,
                        XMLStreamWriter writer)
                 throws 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:
XMLStreamException

writeDocument

public static void writeDocument(org.w3c.dom.Document d,
                                 XMLStreamWriter writer,
                                 boolean repairing)
                          throws XMLStreamException
Throws:
XMLStreamException

writeElement

public static void writeElement(org.w3c.dom.Element e,
                                XMLStreamWriter writer,
                                boolean repairing)
                         throws 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:
XMLStreamException

writeNode

public static void writeNode(org.w3c.dom.Node n,
                             XMLStreamWriter writer,
                             boolean repairing)
                      throws XMLStreamException
Throws:
XMLStreamException

read

public static org.w3c.dom.Document read(javax.xml.parsers.DocumentBuilder builder,
                                        XMLStreamReader reader,
                                        boolean repairing)
                                 throws XMLStreamException
Throws:
XMLStreamException

readDocElements

public static void readDocElements(org.w3c.dom.Node parent,
                                   XMLStreamReader reader,
                                   boolean repairing)
                            throws XMLStreamException
Parameters:
parent -
reader -
Throws:
XMLStreamException

createXMLStreamWriter

public static XMLStreamWriter createXMLStreamWriter(java.io.OutputStream out,
                                                    java.lang.String encoding,
                                                    MessageContext ctx)
Parameters:
out -
encoding -
Returns:

getXMLOutputFactory

public static XMLOutputFactory getXMLOutputFactory(MessageContext ctx)
Returns:

getXMLInputFactory

public static XMLInputFactory getXMLInputFactory(MessageContext ctx)
Returns:

createXMLStreamReader

public static XMLStreamReader createXMLStreamReader(java.io.InputStream in,
                                                    java.lang.String encoding,
                                                    MessageContext ctx)
Parameters:
in -
encoding -
ctx -
Returns:

createXMLStreamReader

public static XMLStreamReader createXMLStreamReader(java.io.Reader reader)

createXMLStreamReader

public static XMLStreamReader createXMLStreamReader(java.io.Reader reader,
                                                    MessageContext context)
Parameters:
reader -
Returns:


Copyright © 2004-2006 Envoi Solutions LLC. All Rights Reserved.