Package org.fest.swing.junit.xml
Class XmlNode
java.lang.Object
org.fest.swing.junit.xml.XmlNode
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.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an attribute to this node.private static void
addAttribute
(Element e, XmlAttribute a) void
addAttributes
(XmlAttribute... attributes) Adds one or more attributes to this node.void
Adds a CDATA section to this node.addNewNode
(String name) Creates and adds a new XML node to this node.addNewNode
(String name, XmlAttributes attributes) Creates and adds a new XML node to this node.void
Adds a text node to this node.int
Returns the number of attributes in this node.child
(int index) Returns the child at the given index.private Element
createAndAddChild
(String name) private Document
document()
boolean
int
hashCode()
name()
Returns the name of this node.Returns the parent node of this node.int
size()
Returns the number of children in this node.target()
Returns the underlying DOM
.Element
text()
Returns the text content of this node.toString()
valueOfAttribute
(String name) Returns the value of the given attribute, or an emptyString
if this node does not contain an attribute with the given name.private static XmlNode
xmlNodeFrom
(Node n)
-
Field Details
-
target
-
-
Constructor Details
-
XmlNode
Creates a newXmlNode
.- Parameters:
target
- the underlying DOM element.
-
-
Method Details
-
addNewNode
Creates and adds a new XML node to this node.- Parameters:
name
- the name of the node to add.- Returns:
- the created node.
-
addNewNode
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.
-
createAndAddChild
-
addCdata
Adds a CDATA section to this node.- Parameters:
data
- the data for the CDATA section to create.
-
addText
Adds a text node to this node.- Parameters:
text
- the text of the new text node.
-
document
-
addAttribute
Adds an attribute to this node.- Parameters:
a
- the attribute to add.
-
addAttributes
Adds one or more attributes to this node.- Parameters:
attributes
- the attribute(s) to add to this node.
-
addAttribute
-
target
Returns the underlying DOM
.Element
- Returns:
- the underlying DOM element.
-
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
Returns the child at the given index.- Parameters:
index
- the given index.- Returns:
- the child at the given index.
-
xmlNodeFrom
-
valueOfAttribute
Returns the value of the given attribute, or an emptyString
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
Returns the name of this node.- Returns:
- the name of this node.
-
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
-
hashCode
public int hashCode() -
toString
-