org.fest.swing.junit.xml
Class XmlNode

java.lang.Object
  extended by org.fest.swing.junit.xml.XmlNode

public class XmlNode
extends Object

Understands a DOM-based XML element. This class is intended for internal use only. It is just a thin wrapper around a DOM Element. It only provides the necessary functionality needed by the FEST-Swing JUnit extension.

Author:
Alex Ruiz

Constructor Summary
protected XmlNode(Element target)
          Creates a new XmlNode.
 
Method Summary
 void addAttribute(XmlAttribute a)
          Adds an attribute to this node.
 void addAttributes(XmlAttribute... attributes)
          Adds one or more attributes to this node.
 void addCdata(String data)
          Adds a CDATA section to this node.
 XmlNode addNewNode(String name)
          Creates and adds a new XML node to this node.
 XmlNode addNewNode(String name, XmlAttributes attributes)
          Creates and adds a new XML node to this node.
 void addText(String text)
          Adds a text node to this node.
 int attributeCount()
          Returns the number of attributes in this node.
 XmlNode child(int index)
          Returns the child at the given index.
 boolean equals(Object obj)
           
 int hashCode()
           
 String name()
          Returns the name of this node.
 XmlNode parentNode()
          Returns the parent node of this node.
 int size()
          Returns the number of children in this node.
 Element target()
          Returns the underlying DOM Element.
 String text()
          Returns the text content of this node.
 String toString()
           
 String valueOfAttribute(String name)
          Returns the value of the given attribute, or an empty String if this node does not contain an attribute with the given name.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XmlNode

protected XmlNode(Element target)
Creates a new XmlNode.

Parameters:
target - the underlying DOM element.
Method Detail

addNewNode

public XmlNode addNewNode(String name)
Creates and adds a new XML node to this node.

Parameters:
name - the name of the node to add.
Returns:
the created node.

addNewNode

public XmlNode addNewNode(String name,
                          XmlAttributes attributes)
Creates and adds a new XML node to this node.

Parameters:
name - the name of the node to add.
attributes - the attributes of the node to add.
Returns:
the created node.

addCdata

public void addCdata(String data)
Adds a CDATA section to this node.

Parameters:
data - the data for the CDATA section to create.

addText

public void addText(String text)
Adds a text node to this node.

Parameters:
text - the text of the new text node.

addAttribute

public void addAttribute(XmlAttribute a)
Adds an attribute to this node.

Parameters:
a - the attribute to add.

addAttributes

public void addAttributes(XmlAttribute... attributes)
Adds one or more attributes to this node.

Parameters:
attributes - the attribute(s) to add to this node.

target

public Element target()
Returns the underlying DOM Element.

Returns:
the underlying DOM element.

parentNode

public XmlNode parentNode()
Returns the parent node of this node.

Returns:
the parent node of this node.

size

public int size()
Returns the number of children in this node.

Returns:
the number of children in this node.

child

public XmlNode child(int index)
Returns the child at the given index.

Parameters:
index - the given index.
Returns:
the child at the given index.

valueOfAttribute

public String valueOfAttribute(String name)
Returns the value of the given attribute, or an empty String if this node does not contain an attribute with the given name.

Parameters:
name - the name of the attribute we are looking for.
Returns:
the value of the attribute with the given name, or an empty String if this node does not contain a matching attribute.

name

public String name()
Returns the name of this node.

Returns:
the name of this node.

text

public String text()
Returns the text content of this node.

Returns:
the text content of this node.

attributeCount

public int attributeCount()
Returns the number of attributes in this node.

Returns:
the number of attributes in this node.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.