Class JNode


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

      Fields 
      Modifier and Type Field Description
      protected org.w3c.dom.Node node  
    • Constructor Summary

      Constructors 
      Constructor Description
      JNode​(org.w3c.dom.Document document, java.lang.String name)
      Constructs a new JNode for a Document.
      JNode​(org.w3c.dom.Node node)
      Creates a Wrapper JNode for a Node element.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      JNode appendChild​(java.lang.String name)
      Append a new JNode with a given name.
      JNode appendChild​(JNode jNode)
      Append a JNode.
      JNode appendChild​(org.w3c.dom.Node node)
      Append an XML Node.
      java.lang.String getAttribute​(java.lang.String attribute)
      Returns the value of an attribute.
      java.util.Map<java.lang.String,​java.lang.String> getAttributes()
      Returns a Map of all attributes.
      JNode getChild()
      Returns the first child.
      JNode getChild​(java.lang.String name)
      Returns the first child with a specified name.
      java.util.List<JNode> getChildren()
      Returns all children.
      java.util.List<JNode> getChildren​(java.lang.String name)
      Returns all children with a specified name.
      org.w3c.dom.Document getDocument()
      Returns the owner Document.
      java.lang.String getName()
      Returns the name.
      org.w3c.dom.Node getNode()
      Retrieves the Node element.
      java.lang.String getText()
      Returns the strings content.
      boolean hasAttribute​(java.lang.String attribute)
      Returns true if the attribute is existent.
      boolean hasText()
      Returns true if this node has a strings content.
      void setAttribute​(java.lang.String attribute, java.lang.String value)
      Sets an attribute to a value.
      void setText​(java.lang.String text)
      Sets the strings content.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • node

        protected final org.w3c.dom.Node node
    • Constructor Detail

      • JNode

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

        public JNode​(org.w3c.dom.Document document,
                     java.lang.String name)
        Constructs a new JNode for a Document.
        Parameters:
        document - the XML document
        name - the specified name of the node
    • Method Detail

      • getNode

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

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

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

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

        public boolean hasAttribute​(java.lang.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​(java.lang.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 java.util.List<JNode> getChildren()
        Returns all children.
        Returns:
        a list of all children.
      • getChildren

        public java.util.List<JNode> getChildren​(java.lang.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 java.lang.String getText()
        Returns the strings content.
        Returns:
        the strings content
        See Also:
        setText(java.lang.String)
      • 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​(java.lang.String text)
        Sets the strings content.
        Parameters:
        text - the strings content to set
        See Also:
        getText()
      • setAttribute

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

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

        public JNode appendChild​(org.w3c.dom.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 org.w3c.dom.Document getDocument()
        Returns the owner Document.
        Returns:
        the owner XML document
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object