com.tensegrity.generic.command
Class CommandRegistry

java.lang.Object
  extended bycom.tensegrity.generic.command.CommandRegistry
Direct Known Subclasses:
SwingCommandRegistry, SwtCommandRegistry

public class CommandRegistry
extends java.lang.Object

Class that manages a map of all commands that are currently registered. Every command to be registered must have a unique name. After registration the CommandRegistry allows for look up of commands by their name. The registration is done while creating a BaseCommand.

Please keep in mind that sometimes if your old commands are not needed any longer or if you keep creating commands dynamically, it may be needed to clear the CommandRegistry. Otherwise the internal hashmap will hang on to the references of its commands forever.

Version:
$Id: CommandRegistry.java,v 1.22 2004/05/26 08:16:16 GillesIachelini Exp $
Author:
Stepan Rutz

Constructor Summary
CommandRegistry()
          Constructs a new CommandRegistry-Instance.
 
Method Summary
 void clear()
          Removes all commands from this Registry-Instance.
 boolean contains(java.lang.String key)
          Returns true, if this instance contains the given key.
 void dump()
          Dumps out the internally used map.
 BaseCommand get(java.lang.String id)
          Looks up an command in the map and returns it, null if none is found with the given key.
 BaseCommand remove(java.lang.String key)
          Removes the specified mapping with key key.
 int size()
          Returns the number of registered commands.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandRegistry

public CommandRegistry()
Constructs a new CommandRegistry-Instance.

Method Detail

get

public BaseCommand get(java.lang.String id)
Looks up an command in the map and returns it, null if none is found with the given key.

Parameters:
id - the unique id of the command to look up.
Returns:
the command associated with the given key; null if there is no such command.

remove

public BaseCommand remove(java.lang.String key)
Removes the specified mapping with key key.

Parameters:
key - the key whose mapping is to be removed from the registry.
Returns:
the previously associated value with specified key; null if there was no mapping for that key.

clear

public void clear()
Removes all commands from this Registry-Instance.


size

public int size()
Returns the number of registered commands.

Returns:
the actual nmuber of registered commands.

dump

public void dump()
Dumps out the internally used map. For debuging-purposes only.


contains

public boolean contains(java.lang.String key)
Returns true, if this instance contains the given key.

Parameters:
key - the key to check.
Returns:
true, if this instance contains the given key.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.