org.palo.api.ext.favoriteviews
Class FavoriteViewTreeNode

java.lang.Object
  extended by org.palo.api.ext.favoriteviews.FavoriteViewTreeNode

public class FavoriteViewTreeNode
extends java.lang.Object

FavoriteViewTreeNode is a specialized tree which stores the favorite views structure of a Connection. You can use the favorite view tree to add FavoriteView or FavoriteViewsFolder objects. While favorite views are the leafs of the tree and thus may not have children, favorite views folders can be added to the tree and can have children (either folders or favorite views). The root of the favorite view tree is always a FavoriteViewsFolder. Example of a favorite view tree (to the left, the name of the element is given, followed by its type in square brackets): RootFolder [FavoriteViewsFolder] | |--- My Favorite View 1 [FavoriteView] |--- Another Folder [FavoriteViewsFolder] | | | |--- My second view [FavoriteView] | |--- My third view [FavoriteView] | |--- My fourth view [FavoriteView] A complete favorite view tree can be loaded from a Connection via the loadFavoriteViews method, which will return the root node of the tree. The tree can also be saved in a connection by using the storeFavoriteViews method, which expects the root node of a favorite views tree, so that it can be saved.

Version:
$ID$

Constructor Summary
FavoriteViewTreeNode(FavoriteViewObject userObject)
          Creates a new FavoriteViewTreeNode with the given user object.
 
Method Summary
 void addChild(FavoriteViewTreeNode child)
          Adds a child at the end of the list of children of this node.
 boolean equals(java.lang.Object obj)
          Two FavoriteViewTreeNodes are considered equal if their user object is equal.
 FavoriteViewTreeNode getChildAt(int index)
          Returns the child at the specified index.
 int getChildCount()
          Returns the number of children of this node.
 FavoriteViewTreeNode[] getChildren()
          Returns all children of this node.
 FavoriteViewTreeNode getParent()
          Returns the parent of this node.
 FavoriteViewObject getUserObject()
          Returns the user object for this tree node.
 boolean hasChildren()
          Returns true if this node has children and false otherwise.
 int hashCode()
          Two FavoriteViewTreeNodes are considered equal if their user object is equal.
 int indexOfChild(FavoriteViewTreeNode child)
          Returns the index of the specified child or -1 if it is not a child of this node.
 void insertChild(int index, FavoriteViewTreeNode child)
          Inserts a child at the given index into the list of children of this node.
 void removeChild(FavoriteViewTreeNode child)
          Removes the specified child from the list of children and sets the child's parent to null.
 void removeChildren()
          Removes all children from this node and sets their parent to null.
 void setParent(FavoriteViewTreeNode parent)
          Sets a new parent for this node.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FavoriteViewTreeNode

public FavoriteViewTreeNode(FavoriteViewObject userObject)
Creates a new FavoriteViewTreeNode with the given user object. The user object can either be a favorite view or a favorite view folder and represents the data of this node.

Parameters:
userObject - the user object for this node.
Method Detail

getUserObject

public FavoriteViewObject getUserObject()
Returns the user object for this tree node. The user object is either a FavoriteView or a FavoriteViewsFolder.

Returns:
the user object for this node.

setParent

public void setParent(FavoriteViewTreeNode parent)
Sets a new parent for this node.

Parameters:
parent - the new parent for this node.

getParent

public FavoriteViewTreeNode getParent()
Returns the parent of this node.

Returns:
this node's parent.

hashCode

public int hashCode()
Two FavoriteViewTreeNodes are considered equal if their user object is equal. Thus the hashCode method is overridden to implement this logic.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Two FavoriteViewTreeNodes are considered equal if their user object is equal. Thus the equals method is overridden to implement this logic.

Overrides:
equals in class java.lang.Object

addChild

public void addChild(FavoriteViewTreeNode child)
Adds a child at the end of the list of children of this node. The parent of the specified node is automatically set to be this node.

Parameters:
child - the node to be added to the list of children.

insertChild

public void insertChild(int index,
                        FavoriteViewTreeNode child)
Inserts a child at the given index into the list of children of this node. If the index is out of bounds, the child will automatically be added at the end of the list of children.

Parameters:
index - the position at which the new child is going to be inserted.
child - the child node to be inserted into the list of children.

removeChild

public void removeChild(FavoriteViewTreeNode child)
Removes the specified child from the list of children and sets the child's parent to null. Note that if the child is not in the list of children of this node, its parent will nevertheless be set to null.

Parameters:
child - the child to be removed from this node.

removeChildren

public void removeChildren()
Removes all children from this node and sets their parent to null.


indexOfChild

public int indexOfChild(FavoriteViewTreeNode child)
Returns the index of the specified child or -1 if it is not a child of this node.

Parameters:
child - the child node of which the index is to be retieved.
Returns:
the index of the child or -1 if this node is not its parent.

getChildren

public FavoriteViewTreeNode[] getChildren()
Returns all children of this node.

Returns:
all children of this node.

getChildCount

public int getChildCount()
Returns the number of children of this node.

Returns:
the number of children of this node.

getChildAt

public FavoriteViewTreeNode getChildAt(int index)
Returns the child at the specified index.

Parameters:
index - the index of the child which is to be retrieved.
Returns:
the child at the specified index.

hasChildren

public boolean hasChildren()
Returns true if this node has children and false otherwise.

Returns:
true if this node has children and false otherwise.