org.apache.axis2.format
Class ElementHelper

java.lang.Object
  extended by org.apache.axis2.format.ElementHelper

public class ElementHelper
extends java.lang.Object

Utility class with methods to work on OMElement objects.

NOTICE: The code in this class will be moved to Axiom (or somewhere else). Use with care!


Method Summary
static java.io.Reader getTextAsStream(org.apache.axiom.om.OMElement element, boolean cache)
          Returns a stream representing the concatenation of the text nodes that are children of a given element.
static void writeTextTo(org.apache.axiom.om.OMElement element, java.io.Writer out, boolean cache)
          Write the content of the text nodes that are children of a given element to a Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTextAsStream

public static java.io.Reader getTextAsStream(org.apache.axiom.om.OMElement element,
                                             boolean cache)
Returns a stream representing the concatenation of the text nodes that are children of a given element. The stream returned by this method produces exactly the same character sequence as the the stream created by the following expression:
new StringReader(element.getText())
The difference is that the stream implementation returned by this method is guaranteed to have constant memory usage and is optimized for performance.

Parameters:
element - the element to read the text nodes from
cache - whether to enable caching when accessing the element
Returns:
a stream representing the concatenation of the text nodes
See Also:
OMElement.getText()

writeTextTo

public static void writeTextTo(org.apache.axiom.om.OMElement element,
                               java.io.Writer out,
                               boolean cache)
                        throws javax.xml.stream.XMLStreamException,
                               java.io.IOException
Write the content of the text nodes that are children of a given element to a Writer. If cache is true, this method has the same effect as the following instruction:
out.write(element.getText())
The difference is that this method is guaranteed to have constant memory usage and is optimized for performance.

Parameters:
element - the element to read the text nodes from
out - the stream to write the content to
cache - whether to enable caching when accessing the element
Throws:
javax.xml.stream.XMLStreamException - if an error occurs when reading from the element
java.io.IOException - if an error occurs when writing to the stream
See Also:
OMElement.getText()


Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.