org.openbp.jaspira.action.keys
Class KeyTree

java.lang.Object
  extended by org.openbp.jaspira.action.keys.KeyTree

public class KeyTree
extends java.lang.Object

Tree over keysequences. Provides for a given key-sequences the number of sub-sequences.

Author:
Stephan Moritz

Constructor Summary
KeyTree()
          Creates a root tree.
KeyTree(KeyTree parent, KeySequence sequence)
          Creates a new sub tree with the given parent and keystroke.
 
Method Summary
 void addSequence(KeySequence sequence)
          Adds the given sequence to the tree, creating branches as necessary.
 int getNumberOfChildren()
          Returns the number of possible keys fom here.
 KeySequence getSequence()
           
 KeyTree getSubTree(javax.swing.KeyStroke stroke)
          Returns the sub tree for the given keystroke.
 boolean hasChildren()
          Returns true if this sub tree has any keys that lead further.
 javax.swing.KeyStroke[] keys()
          Returns all children key strokes.
 boolean removeSequence(KeySequence sequence)
          Removes a sequence from the tree, deleting obsolete branches.
 KeyTree[] subTrees()
          Returns all sub trees.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeyTree

public KeyTree()
Creates a root tree.


KeyTree

public KeyTree(KeyTree parent,
               KeySequence sequence)
Creates a new sub tree with the given parent and keystroke.

Parameters:
parent - Parent tree or null
sequence - Remaining key sequence
Method Detail

addSequence

public void addSequence(KeySequence sequence)
Adds the given sequence to the tree, creating branches as necessary.

Parameters:
sequence - Sequence to add

removeSequence

public boolean removeSequence(KeySequence sequence)
Removes a sequence from the tree, deleting obsolete branches.

Parameters:
sequence - Sequence to remove
Returns:
true There are still references to this tree
false No references left, the tree can be removed

hasChildren

public boolean hasChildren()
Returns true if this sub tree has any keys that lead further.


getNumberOfChildren

public int getNumberOfChildren()
Returns the number of possible keys fom here.


getSubTree

public KeyTree getSubTree(javax.swing.KeyStroke stroke)
Returns the sub tree for the given keystroke.

Parameters:
stroke - Key stroke to check
Returns:
The tree or null if the key stroke does not have a sub tree associated

keys

public javax.swing.KeyStroke[] keys()
Returns all children key strokes.

Returns:
The child keys (can ben empty, but not null)

subTrees

public KeyTree[] subTrees()
Returns all sub trees.

Returns:
The sub trees (can ben empty, but not null)

getSequence

public KeySequence getSequence()

toString

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


Copyright © 2011. All Rights Reserved.