Cytoscape 2.8.0 API

cytoscape.command
Class CyCommandManager

java.lang.Object
  extended by cytoscape.command.CyCommandManager

public class CyCommandManager
extends Object

CyCommandManager is a singleton Cytoscape class that provides a global registry of CyCommands and CyCommandNamespaces. Each CyCommand is added to the registry through the register method. Commands may be accessed with a combination of command name and namespace.


Constructor Summary
CyCommandManager()
           
 
Method Summary
static CyCommandResult execute(String namespace, String command, List<Tunable> arguments)
          Execute a command
static CyCommandResult execute(String namespace, String command, Map<String,Object> arguments)
          Execute a command.
static CyCommandHandler getCommand(String namespace, String name)
          return a CyCommandHandler by either name or class name.
static List<String> getCommandList(String namespace)
          Get the list of all commands that are currently registered for the specified namespace.
static Map<String,List<CyCommandHandler>> getCommandMap()
          Get the list of all commands that are currently registered, organized by namespaces
static List<String> getNamespaceList()
          Get the list of all of the currently registered namespaces.
static void register(CyCommandNamespace ns, String command, CyCommandHandler com)
          register a new CyCommandHandler.
static CyCommandNamespace reserveNamespace(String namespace)
          Reserve a namespace.
static CyCommandNamespace reserveNamespace(String namespace, double minVersion, double maxVersion)
          Reserve a namespace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CyCommandManager

public CyCommandManager()
Method Detail

reserveNamespace

public static CyCommandNamespace reserveNamespace(String namespace,
                                                  double minVersion,
                                                  double maxVersion)
                                           throws RuntimeException
Reserve a namespace. In general, a namespace will map to a plugin and serve to reserve a command prefix to avoid conflict between plugins. A very rudimentary versioning system (minimum/maximum version numbers) provide for some version management.

Parameters:
namespace - the name of the namespace
minVersion - the minimum version this set of commands supports
maxVersion - the maximum version this set of commands supports
Throws:
RuntimeException - if a namespace by the requested name already exists

reserveNamespace

public static CyCommandNamespace reserveNamespace(String namespace)
                                           throws RuntimeException
Reserve a namespace. In general, a namespace will map to a plugin and serve to reserve a command prefix to avoid conflict between plugins. This version of the call assumes a version of 0.0 for the min verison and 1.0 for the max version.

Parameters:
namespace - the name of the namespace
Throws:
RuntimeException - if a namespace by the requested name already exists

register

public static void register(CyCommandNamespace ns,
                            String command,
                            CyCommandHandler com)
                     throws RuntimeException
register a new CyCommandHandler.

Parameters:
ns - the namespace for this command
command - the command string that identified this command
com - the command handler for the command we want to register
Throws:
RuntimeException - if the command is already registered

getCommand

public static CyCommandHandler getCommand(String namespace,
                                          String name)
return a CyCommandHandler by either name or class name.

Parameters:
name - either the name of the class or command
Returns:
the command, or null if a command with name or class doesn't exist

getNamespaceList

public static List<String> getNamespaceList()
Get the list of all of the currently registered namespaces. Note that only the name of the namespace is returned. Only the plugin that registered the namespace may have access to the namespace object itself.

Returns:
list of namespaces

getCommandMap

public static Map<String,List<CyCommandHandler>> getCommandMap()
Get the list of all commands that are currently registered, organized by namespaces

Returns:
the map of commands that are currently registered, with the namespaced used to register that command as a key

getCommandList

public static List<String> getCommandList(String namespace)
Get the list of all commands that are currently registered for the specified namespace.

Parameters:
namespace - the namespace of the commands to retrieve.
Returns:
the list of commands that are currently registered

execute

public static CyCommandResult execute(String namespace,
                                      String command,
                                      Map<String,Object> arguments)
                               throws CyCommandException,
                                      RuntimeException
Execute a command.

Parameters:
namespace - the namespace for this command
command - the command
arguments - the argument list to pass to the command
Returns:
the CyCommandResult
Throws:
RuntimeException - is the namespace or command is not yet registered
CyCommandException - if there is an error with the execution

execute

public static CyCommandResult execute(String namespace,
                                      String command,
                                      List<Tunable> arguments)
                               throws CyCommandException,
                                      RuntimeException
Execute a command

Parameters:
namespace - the namespace for this command
command - the command
arguments - the argument list to pass to the command
Returns:
the CyCommandResult
Throws:
RuntimeException - is the namespace or command is not yet registered
CyCommandException - if there is an error with the execution

Cytoscape 2.8.0 API

Copyright 2010 Cytoscape Consortium. All rights reserved.