Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.metacosm.framework.parser
Class CommandsManager  view CommandsManager download CommandsManager.java

java.lang.Object
  extended byorg.metacosm.framework.parser.CommandsManager

public final class CommandsManager
extends java.lang.Object

Manages associations between commands name(s) and commands, both for PlayerCommands and ControllerCommands.
Commands are loaded from two files (names given by Configuration).
Used by the parser to find commands first, and then to execute them.
It's a Singleton OOD pattern.


Field Summary
private static java.util.Map controllerCommands
          All commands for Controller
private static java.lang.String error
          Error message, for problems while reading configuration files
private static CommandsManager manager
          The instance of the class
private static java.util.Map playerCommands
          All commands for Player
private static java.util.Map reverseMap
          Reversed (multi)map: key is classes fullname and values are a list of commands
 
Constructor Summary
protected CommandsManager()
          The constructor is private because of singleton pattern.
 
Method Summary
 void addControllerCommand(java.lang.String className, java.lang.String cmdName)
          Associates a ControllerCommand and its name.
private  void addControllerCommands(java.util.Properties controllerCommandsProps)
          Adds loaded controller commands from properties.
 void addPlayerCommand(java.lang.String className, java.lang.String cmdName)
          Associates a PlayerCommand and its name.
private  void addPlayerCommands(java.util.Properties playerCommandsProps)
          Adds loaded player commands from properties.
 boolean containsControllerCommand(java.lang.String cmdName)
          Tests if a ControllerCommand exists.
 boolean containsPlayerCommand(java.lang.String cmdName)
          Tests if a PlayerCommand exists.
 org.metacosm.framework.command.ControllerCommand getControllerCommand(java.lang.String cmdName)
           
static CommandsManager getInstance()
          Loads commands from the two configuration files.
 int getNbControllerCommands()
           
 int getNbPlayerCommands()
           
 org.metacosm.framework.command.PlayerCommand getPlayerCommand(java.lang.String cmdName)
           
 java.util.Set getPlayerCommandsKeySet()
           
 void remove(org.metacosm.framework.command.ControllerCommand cmd)
          Removes the link between the given command name and its associated ControllerCommand.
 void remove(org.metacosm.framework.command.PlayerCommand cmd)
          Removes the link between the given command name and its associated PlayerCommand.
 void remove(java.lang.String cmd)
          Removes the link between the given command name and its associated command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

manager

private static CommandsManager manager
The instance of the class


error

private static java.lang.String error
Error message, for problems while reading configuration files


playerCommands

private static java.util.Map playerCommands
All commands for Player

See Also:
Player, org.metacosm.framework.command.PlayerCommand

controllerCommands

private static java.util.Map controllerCommands
All commands for Controller

See Also:
AbstractController, org.metacosm.framework.command.ControllerCommand

reverseMap

private static java.util.Map reverseMap
Reversed (multi)map: key is classes fullname and values are a list of commands

Constructor Detail

CommandsManager

protected CommandsManager()
The constructor is private because of singleton pattern.

Method Detail

getInstance

public static CommandsManager getInstance()
Loads commands from the two configuration files.


addPlayerCommand

public void addPlayerCommand(java.lang.String className,
                             java.lang.String cmdName)
                      throws java.lang.IllegalArgumentException
Associates a PlayerCommand and its name.


addControllerCommand

public void addControllerCommand(java.lang.String className,
                                 java.lang.String cmdName)
                          throws java.lang.IllegalArgumentException
Associates a ControllerCommand and its name.


remove

public void remove(java.lang.String cmd)
Removes the link between the given command name and its associated command.


remove

public void remove(org.metacosm.framework.command.PlayerCommand cmd)
Removes the link between the given command name and its associated PlayerCommand.


remove

public void remove(org.metacosm.framework.command.ControllerCommand cmd)
Removes the link between the given command name and its associated ControllerCommand.


containsPlayerCommand

public boolean containsPlayerCommand(java.lang.String cmdName)
Tests if a PlayerCommand exists.


containsControllerCommand

public boolean containsControllerCommand(java.lang.String cmdName)
Tests if a ControllerCommand exists.


getPlayerCommand

public org.metacosm.framework.command.PlayerCommand getPlayerCommand(java.lang.String cmdName)

getControllerCommand

public org.metacosm.framework.command.ControllerCommand getControllerCommand(java.lang.String cmdName)

getPlayerCommandsKeySet

public java.util.Set getPlayerCommandsKeySet()

getNbPlayerCommands

public int getNbPlayerCommands()

getNbControllerCommands

public int getNbControllerCommands()

addPlayerCommands

private void addPlayerCommands(java.util.Properties playerCommandsProps)
Adds loaded player commands from properties.


addControllerCommands

private void addControllerCommands(java.util.Properties controllerCommandsProps)
Adds loaded controller commands from properties.