gishur.core
Class SimpleTreeItem

java.lang.Object
  |
  +--gishur.core.BasicTreeItem
        |
        +--gishur.core.SimpleTreeItem
All Implemented Interfaces:
java.lang.Cloneable, Cloneable, ControlledCloneable, KeyValueHolder, java.io.Serializable, TreeItem

public class SimpleTreeItem
extends BasicTreeItem

A simple binary tree node containing only one value. The stored value can be changed with setKey(java.lang.Object) as well as with setValue(java.lang.Object). According to this feature of SimpleTreeItems, key() and value() return the same object and if one tries to change the value of a SimpleTreeItem, the Owner is asked for permission to change the key.

Version:
1.0
Author:
Thomas Wolf
See Also:
Serialized Form

Fields inherited from interface gishur.core.TreeItem
CLEAR_CONNECTIONS, CONNECT, CONNECT_PARENT, LAST_CHILD, LEFT, PARENT, REMOVE, RIGHT, SET_BALANCE, SET_MAX_RANK, SET_OWNER, UNKNOWN
 
Fields inherited from interface gishur.core.KeyValueHolder
SET_KEY, SET_VALUE
 
Fields inherited from interface gishur.core.ControlledCloneable
DEEP, FLAT
 
Constructor Summary
SimpleTreeItem(int maxrank)
          The standard constructor.
SimpleTreeItem(int maxrank, java.lang.Object key)
          Constructor performing an initialization of the stored value. {
 
Method Summary
 java.lang.Object key()
          Returns the stored key of this SimpleTreeItem.
 boolean setKey(java.lang.Object key)
          Sets the key to key.
 boolean setValue(java.lang.Object object)
          Stores the object object (equivalent to setKey(Object).
 java.lang.String toString()
          Overrides Object.toString().
 java.lang.Object value()
          Returns the stored value (which is the same as the key for SimpleTreeItems).
 
Methods inherited from class gishur.core.BasicTreeItem
answerConnect, balance, child, clearConnections, clone, clone, connect, cut, equals, getOwningTree, isInner, isLeaf, isRoot, level, maxRank, nextChildPos, parent, pos, prevChildPos, rank, remove, requestTreeAccess, setBalance, setMaxRank, setOwningTree, sibling
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleTreeItem

public SimpleTreeItem(int maxrank)
The standard constructor. The stored value will be set to null.
Parameters:
maxrank - maximal rank, i.e. the maximal number of child-nodes

SimpleTreeItem

public SimpleTreeItem(int maxrank,
                      java.lang.Object key)
Constructor performing an initialization of the stored value. BasicTree.requestAccess(int, java.lang.Object, java.lang.Object) will not be called!
Parameters:
maxrank - maximal rank, i.e. the maximal number of child-nodes
key - object to store in the node
Method Detail

toString

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

key

public java.lang.Object key()
Returns the stored key of this SimpleTreeItem.
Overrides:
key in class BasicTreeItem
Returns:
the key

setKey

public boolean setKey(java.lang.Object key)
Sets the key to key.
Overrides:
setKey in class BasicTreeItem
Parameters:
key - new key-object

value

public java.lang.Object value()
Returns the stored value (which is the same as the key for SimpleTreeItems).
Overrides:
value in class BasicTreeItem
Returns:
stored object

setValue

public boolean setValue(java.lang.Object object)
Stores the object object (equivalent to setKey(Object).
Overrides:
setValue in class BasicTreeItem
Parameters:
object - the object to store in this node