Class XmlNode

java.lang.Object
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.
  • Field Details

    • target

      private final Element target
  • Constructor Details

    • XmlNode

      protected XmlNode(Element target)
      Creates a new XmlNode.
      Parameters:
      target - the underlying DOM element.
  • Method Details

    • 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.
    • createAndAddChild

      private Element createAndAddChild(String name)
    • 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.
    • document

      private Document document()
    • 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.
    • addAttribute

      private static void addAttribute(Element e, XmlAttribute a)
    • 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.
    • xmlNodeFrom

      private static XmlNode xmlNodeFrom(Node n)
    • 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