qflib 0.98.1

de.qfs.lib.tree
Interface MutableTreeAdapter

All Superinterfaces:
TreeAdapter

public interface MutableTreeAdapter
extends TreeAdapter

This extension of the TreeAdapter interface has to be implemented in order to support mutable tree hierarchies.

Since:
0.98.1
Version:
$Revision: 1.2 $
Author:
Gregor Schmid

Method Summary
 boolean addNode(java.lang.Object parent, int index, java.lang.Object child)
          Add a child at a given index to a node.
 boolean addNode(java.lang.Object parent, java.lang.Object child)
          Add a child to the end of a node's children.
 java.lang.Object cloneNode(java.lang.Object node)
          Create a shallow copy of a node, similar to Object.clone, but with the parent of the copy set to null.
 boolean insertNodeAfter(java.lang.Object parent, java.lang.Object child, java.lang.Object ref)
          Insert a child node after another node.
 boolean insertNodeBefore(java.lang.Object parent, java.lang.Object child, java.lang.Object ref)
          Insert a child node before another node.
 java.lang.Object removeNode(java.lang.Object parent, int index)
          Remove a child from a node at a given index.
 boolean removeNode(java.lang.Object parent, java.lang.Object child)
          Remove a child from the node.
 void setParentNode(java.lang.Object child, java.lang.Object parent)
          Set the parent of a node.
 
Methods inherited from interface de.qfs.lib.tree.TreeAdapter
getChildCount, getChildNode, getChildren, getFirstChildNode, getIndexOfChildNode, getLastChildNode, getNextSibling, getParentNode, getPreviousSibling, isEnumerationBased, isIndexBased, isLeaf, isLinkBased
 

Method Detail

setParentNode

public void setParentNode(java.lang.Object child,
                          java.lang.Object parent)
Set the parent of a node.
Parameters:
child - The node whose parent to set.
parent - The parent to set.

addNode

public boolean addNode(java.lang.Object parent,
                       java.lang.Object child)
Add a child to the end of a node's children.
Parameters:
parent - The node to add the child to.
child - The child to add.
Returns:
True if the child could be added, false if not

removeNode

public boolean removeNode(java.lang.Object parent,
                          java.lang.Object child)
Remove a child from the node.
Parameters:
parent - The node to remove the child from.
child - The child to remove.
Returns:
True if the child was removed, false if the removal failed or the child is not a child of this node.

addNode

public boolean addNode(java.lang.Object parent,
                       int index,
                       java.lang.Object child)
Add a child at a given index to a node.
Parameters:
parent - The node to add the child to.
index - The index at which to insert.
child - The child to insert.
Returns:
True if the child could be added, false if not

removeNode

public java.lang.Object removeNode(java.lang.Object parent,
                                   int index)
                            throws java.lang.IndexOutOfBoundsException
Remove a child from a node at a given index.
Parameters:
parent - The node to remove the child from.
index - The index from which to remove.
Returns:
The node that was removed or null if the removal failed.
Throws:
java.lang.IndexOutOfBoundsException - If the index is invalid.

insertNodeBefore

public boolean insertNodeBefore(java.lang.Object parent,
                                java.lang.Object child,
                                java.lang.Object ref)
Insert a child node before another node. If the reference node is null, add the child as the last child.
Parameters:
parent - The node to add the child to.
child - The child to insert.
ref - The reference node to insert the child before.
Returns:
True if the child could be added, false if not

insertNodeAfter

public boolean insertNodeAfter(java.lang.Object parent,
                               java.lang.Object child,
                               java.lang.Object ref)
Insert a child node after another node. If the reference node is null, add the child as the first child.
Parameters:
parent - The node to add the child to.
child - The child to insert.
ref - The reference node to insert the child after.
Returns:
True if the child could be added, false if not

cloneNode

public java.lang.Object cloneNode(java.lang.Object node)
Create a shallow copy of a node, similar to Object.clone, but with the parent of the copy set to null.

Also the copy of the node should not have any children.

Parameters:
node - The node to copy.
Returns:
A copy of the node.

qflib 0.98.1