Package org.javlo.xml

Class NodeXML

  • All Implemented Interfaces:
    Cloneable

    public class NodeXML
    extends Object
    implements Cloneable
    Version:
    1.0
    Author:
    pvanderm
    • Field Detail

      • DEBUG

        public static boolean DEBUG
    • Constructor Detail

      • NodeXML

        public NodeXML​(Node node)
        Creates new NodeXML
      • NodeXML

        public NodeXML​(Document doc)
    • Method Detail

      • getChild

        public NodeXML getChild()
        get the first child node (pvdm)
      • getChild

        public NodeXML getChild​(String name)
        get the first child node with a specific name (gh)
        Parameters:
        name - name of the node needed (gh)
        Returns:
        the node as a NodeXML if matching name, null otherwise (gh)
      • getParent

        public NodeXML getParent()
        get the first child node (pvdm)
      • getNext

        public NodeXML getNext()
        get the next node (pvdm)
      • getNext

        public NodeXML getNext​(String name)
        get the next node (pvdm)
        Parameters:
        name - return the next node with this name (pvdm)
      • getName

        public String getName()
        Returns:
        the name of the node (pvdm)
      • getAttributeValue

        public String getAttributeValue​(String attribute)
        get a attribute value (pvdm)
      • getAttributeValue

        public String getAttributeValue​(String attribute,
                                        String standardValue)
        get a attribute value, with a standard value if the attribute is not found.
        Parameters:
        attribute - the name of the attribute
        standardValue - the standard value if attribute not found.
        Returns:
        the attribute value if exist else the standard value.
      • attributeExist

        public boolean attributeExist​(String attribute)
        get a attribute value (pvdm)
      • error

        protected void error​(String message)
        print error message on the screen (pvdm)
      • searchChild

        public NodeXML searchChild​(String name,
                                   String paramName,
                                   String paramValue)
        search a node with a specific value for a parameter (pvdm)
        Parameters:
        name - the name of the node (pvdm)
        paramName - the name of the attribute of the node (pvdm)
        paramValue - the value of the attribute (pvdm)
        Returns:
        renturn the node fund with this specification (pvdm)
      • getContent

        public String getContent()
        get the first text content of the node, if any (grh)
      • getContentPrefix

        public String getContentPrefix()
      • getContentSuffix

        public String getContentSuffix()
      • getOwnerDocument

        public Document getOwnerDocument()
      • getNode

        public Node getNode()
      • addAttribute

        public void addAttribute​(String name)
        Method addAttribute adds an attribute to a node with all attributes value to null, so you still have to do a setAttribute to add value.
        Parameters:
        name - name of the new attribute.
      • setAttribute

        public void setAttribute​(String name,
                                 String value)
        Method setAttribute sets an attrinute to its value, if the attribute does not exist it will be added. @see
        Parameters:
        name - of the attribute.
        value - of the attribute.
      • setContent

        public void setContent​(String content)
      • setCDATAContent

        public void setCDATAContent​(String content)
        setCDATAContent: Set a CDATA content in a DOM, Will add a new CDATA node if there is none. (xcosyns)
        Parameters:
        content - The content to have as a CDATA section in your node.
      • removeChild

        public void removeChild​(NodeXML n)
      • nodeToString

        public String nodeToString()
      • getParentDistance

        public int getParentDistance​(NodeXML inParent)
        return the distance in node count form a prent
        Parameters:
        inParent -
        Returns:
        -1 if not found.
      • main

        public static void main​(String[] args)