Class CommandCollection


  • public class CommandCollection
    extends java.lang.Object
    this class represents a collection of commands. it can be used by command objects to house their subcommands. when execute() method is called, the appropriate subcommand is looked up and executed
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map subCommands  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(IConsoleCommand command)
      adds the specified console command as a subcommand to this object.
      void execute​(java.lang.String commandName, ConsoleInput ci, java.util.List args)
      determines the appropriate subcommand to execute and then executes it, passing in the arguments that we received
      IConsoleCommand get​(java.lang.String commandName)
      returns the sub command with the specified command name
      java.lang.String getCommandDescriptions()
      constructs a string with the descriptions of all of the subcommands, each separated by a newline
      java.util.Iterator iterator()
      gets the set of IConsoleCommand objects that are all of the subcommands that this object owns
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • subCommands

        private final java.util.Map subCommands
    • Constructor Detail

      • CommandCollection

        public CommandCollection()
    • Method Detail

      • execute

        public void execute​(java.lang.String commandName,
                            ConsoleInput ci,
                            java.util.List args)
        determines the appropriate subcommand to execute and then executes it, passing in the arguments that we received
        Parameters:
        commandName -
        ci -
        args -
      • getCommandDescriptions

        public java.lang.String getCommandDescriptions()
        constructs a string with the descriptions of all of the subcommands, each separated by a newline
        Returns:
      • get

        public IConsoleCommand get​(java.lang.String commandName)
        returns the sub command with the specified command name
        Parameters:
        commandName -
        Returns:
      • add

        public void add​(IConsoleCommand command)
        adds the specified console command as a subcommand to this object. we will therefore respond to all of the subcommands command names when passed as the first argument to this command
        Parameters:
        command -
      • iterator

        public java.util.Iterator iterator()
        gets the set of IConsoleCommand objects that are all of the subcommands that this object owns
        Returns: