add getChild(E)
[jSite2.git] / src / net / pterodactylus / util / data / Node.java
index 7737d50..560fc34 100644 (file)
@@ -54,6 +54,58 @@ public interface Node<E> extends Iterable<Node<E>> {
        public Node<E> getChild(int index);
 
        /**
+        * Returns the direct child node that contains the given element.
+        * 
+        * @param element
+        *            The element
+        * @return The direct child node containing the given element, or
+        *         <code>null</code> if this node does not have a child node
+        *         containing the given element
+        */
+       public Node<E> getChild(E element);
+
+       /**
+        * Returns whether the given node is a direct child of this node.
+        * 
+        * @param childNode
+        *            The child node
+        * @return <code>true</code> if the given node is a direct child of this
+        *         node, <code>false</code> otherwise
+        */
+       public boolean hasChild(Node<E> childNode);
+
+       /**
+        * Returns whether this node contains a child node containing the given
+        * element.
+        * 
+        * @param element
+        *            The element
+        * @return <code>true</code> if this node contains a direct child node
+        *         containing the given element, <code>false</code> otherwise
+        */
+       public boolean hasChild(E element);
+
+       /**
+        * Returns the index of the given child node.
+        * 
+        * @param childNode
+        *            The child node
+        * @return The index of the child node, or <code>-1</code> if the child
+        *         node is not a child node of this node
+        */
+       public int getIndexOfChild(Node<E> childNode);
+
+       /**
+        * Returns the index of the child node containing the given element.
+        * 
+        * @param element
+        *            The element
+        * @return The index of the child node, or <code>-1</code> if the child
+        *         node is not a child node of this node
+        */
+       public int getIndexOfChild(E element);
+
+       /**
         * Remove the given child node from this node. If the given node is not a
         * child of this node, nothing happens.
         * 
@@ -80,8 +132,24 @@ public interface Node<E> extends Iterable<Node<E>> {
        public void removeChild(int childIndex);
 
        /**
+        * Removes all children from this node.
+        */
+       public void removeAllChildren();
+
+       /**
         * {@inheritDoc}
         */
        public Iterator<Node<E>> iterator();
 
+       /**
+        * Searches this node’s children recursively for a node that contains the
+        * given element.
+        * 
+        * @param element
+        *            The element to search
+        * @return The node that contains the given element, or <code>null</code>
+        *         if no node could be found
+        */
+       public Node<E> findChild(E element);
+
 }
\ No newline at end of file