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(javax.xml.stream.XMLStreamReader reader, javax.xml.stream.XMLStreamWriter writer)
          Copies the reader to the writer.
static javax.xml.stream.XMLStreamReader createXMLStreamReader(java.io.InputStream in, java.lang.String encoding)
           
static javax.xml.stream.XMLStreamReader createXMLStreamReader(java.io.Reader reader)
           
static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(java.io.OutputStream out, java.lang.String encoding)
           
static org.w3c.dom.Document read(javax.xml.parsers.DocumentBuilder builder, javax.xml.stream.XMLStreamReader reader)
           
static void readElements(org.w3c.dom.Element parent, javax.xml.stream.XMLStreamReader reader)
           
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 writeElement(org.w3c.dom.Element e, javax.xml.stream.XMLStreamWriter writer)
          Writes an Element to an XMLStreamWriter.
 
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(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

writeElement

public static void writeElement(org.w3c.dom.Element e,
                                javax.xml.stream.XMLStreamWriter writer)
                         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

read

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

readElements

public static void readElements(org.w3c.dom.Element parent,
                                javax.xml.stream.XMLStreamReader reader)
                         throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

createXMLStreamWriter

public static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(java.io.OutputStream out,
                                                                     java.lang.String encoding)

createXMLStreamReader

public static javax.xml.stream.XMLStreamReader createXMLStreamReader(java.io.InputStream in,
                                                                     java.lang.String encoding)

createXMLStreamReader

public static javax.xml.stream.XMLStreamReader createXMLStreamReader(java.io.Reader reader)


Copyright © 2004-2005 Codehaus. All Rights Reserved.