示例#1
0
  private void executeInstruction(String[] exeInstruction, ShellMethods curShell)
      throws IOException, ShellInterruptionException {
    if ((exeInstruction.length == 0) || (exeInstruction[0].equals(""))) {
      return;
    }

    BasicCommand exeCommand = curShell.getCommandToExecute(exeInstruction[0]);

    if (null == exeCommand) {
      throw new IOException("unknown instruction: " + exeInstruction[0]);
    }

    if (exeInstruction.length > exeCommand.getNumberOfArguments() + 1) {
      throw new IOException("too many arguments for " + exeInstruction[0]);
    } else if (exeInstruction.length < exeCommand.getNumberOfArguments() + 1) {
      throw new IOException("too less arguments for " + exeInstruction[0]);
    }

    exeCommand.executeCommand(Arrays.copyOfRange(exeInstruction, 1, exeInstruction.length), this);
  }
示例#2
0
 public void loadCommand(BasicCommand currentCommand) {
   loadedCommands.put(currentCommand.getCommandName(), currentCommand);
 }