net.sourceforge.xwing.dom
Class NodeTextUtils

java.lang.Object
  extended bynet.sourceforge.xwing.dom.NodeTextUtils

public class NodeTextUtils
extends Object


Method Summary
static String getText(Node node)
          Retrieves the text of the given node.
static void setText(Node node, String text)
          Sets the text of the given node.The exact behavior depends on the type of node passed in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setText

public static void setText(Node node,
                           String text)
Sets the text of the given node.The exact behavior depends on the type of node passed in. If the node is an Element, its first child Text node is set. If there is no child text node, a new one containing the specified text is appended to the element. If the specified text is null, the first Text child (if any) is removed. If the node is an Attr, its value is set. If the specified text is null, the attr is removed from its owning element. If the node is any CharacterData type, its value is set. If the specified text is null, the node is removed from its parent. No action is taken for any other type of Node.

Parameters:
node - The node whose text should be set.
text - The text to set.

getText

public static String getText(Node node)
Retrieves the text of the given node. The exact behavior depends on the type of node passed in. If the node is an Element, the value of its first child Text node is returned. if the element has no Text children, null is returned. If the node is an Attr or any CharacterData type, its value is returned. Any other type of Node will return null.

Parameters:
node -
Returns:
The corresponding node text


Copyright © 2003 The Xwing Project. All Rights Reserved.