/**
   * This method is called back when input is available. It implements the Template Method pattern
   * to perform the sequence of steps associated with processing expression tree application
   * commands.
   */
  public void handleInput() throws Exception {
    /** Call a hook method to obtain user input. */
    promptUser();

    /** Retrieves input from user. */
    String input = retrieveInput();

    if (input.equals("")) InputDispatcher.instance().endInputDispatching();
    else {
      /** Call a hook method to make a command based on the user input. */
      UserCommand command = makeUserCommand(input);

      /** Call a hook method to execute the command. */
      executeCommand(command);

      /** Saves last command to a variable. */
      lastValidCommand = command;

      /** Displays the menu associated the the command. */
      command.printValidCommands(verboseField);
    }
  }
 /** This hook method executes a command. */
 void executeCommand(UserCommand command) throws Exception {
   command.execute();
 }