Class JNode

java.lang.Object
org.opt4j.config.JNode

public class JNode extends Object
Wrapper for Node elements. This class integrates Java 5 functionality with generics.
  • Field Details

    • node

      protected final Node node
  • Constructor Details

    • JNode

      public JNode(Node node)
      Creates a Wrapper JNode for a Node element.
      Parameters:
      node - the node to wrap
    • JNode

      public JNode(Document document, String name)
      Constructs a new JNode for a Document.
      Parameters:
      document - the XML document
      name - the specified name of the node
  • Method Details

    • getNode

      public Node getNode()
      Retrieves the Node element.
      Returns:
      the XML node
    • getName

      public String getName()
      Returns the name.
      Returns:
      the name
    • getAttributes

      public Map<String,String> getAttributes()
      Returns a Map of all attributes.
      Returns:
      a map of all attributes
    • getAttribute

      public String getAttribute(String attribute)
      Returns the value of an attribute.
      Parameters:
      attribute - the name of the attribute
      Returns:
      the value of the attribute
      See Also:
    • hasAttribute

      public boolean hasAttribute(String attribute)
      Returns true if the attribute is existent.
      Parameters:
      attribute - the name of the attribute
      Returns:
      the value of the attribute
    • getChild

      public JNode getChild()
      Returns the first child.
      Returns:
      the first child
    • getChild

      public JNode getChild(String name)
      Returns the first child with a specified name.
      Parameters:
      name - the name of the child
      Returns:
      the first child with the specified name
    • getChildren

      public List<JNode> getChildren()
      Returns all children.
      Returns:
      a list of all children.
    • getChildren

      public List<JNode> getChildren(String name)
      Returns all children with a specified name.
      Parameters:
      name - the name of the children
      Returns:
      a list of all children with the specified name
    • getText

      public String getText()
      Returns the strings content.
      Returns:
      the strings content
      See Also:
    • hasText

      public boolean hasText()
      Returns true if this node has a strings content.
      Returns:
      true if this node has a strings content
    • setText

      public void setText(String text)
      Sets the strings content.
      Parameters:
      text - the strings content to set
      See Also:
    • setAttribute

      public void setAttribute(String attribute, String value)
      Sets an attribute to a value.
      Parameters:
      attribute - the name of the attribute
      value - the value
      See Also:
    • appendChild

      public JNode appendChild(String name)
      Append a new JNode with a given name.
      Parameters:
      name - the specified name
      Returns:
      the appended JNode
    • appendChild

      public JNode appendChild(Node node)
      Append an XML Node.
      Parameters:
      node - the XML node
      Returns:
      the appended JNode
    • appendChild

      public JNode appendChild(JNode jNode)
      Append a JNode.
      Parameters:
      jNode - the node to append
      Returns:
      the appended JNode
    • getDocument

      public Document getDocument()
      Returns the owner Document.
      Returns:
      the owner XML document
    • toString

      public String toString()
      Overrides:
      toString in class Object