00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 package com.realtime.crossfire.jxclient.commands;
00023
00024 import com.realtime.crossfire.jxclient.gui.textinput.CommandExecutor;
00025 import com.realtime.crossfire.jxclient.queue.CommandQueue;
00026 import org.jetbrains.annotations.NotNull;
00027
00032 public class CommandExecutorImpl implements CommandExecutor {
00033
00037 @NotNull
00038 private final CommandQueue commandQueue;
00039
00043 @NotNull
00044 private final Commands commands;
00045
00051 public CommandExecutorImpl(@NotNull final CommandQueue commandQueue, @NotNull final Commands commands) {
00052 this.commandQueue = commandQueue;
00053 this.commands = commands;
00054 }
00055
00059 @Override
00060 public void executeCommand(@NotNull final CharSequence commandLine) {
00061 final Iterable<CommandExec> commandList = CommandExpander.expand(commandLine, commands);
00062 for (final CommandExec commandExec : commandList) {
00063 final Command command = commandExec.getCommand();
00064 if (command == null) {
00065 commandQueue.sendNcom(false, commandExec.getArgs());
00066 } else {
00067 command.execute(commandExec.getArgs());
00068 }
00069 }
00070 }
00071
00072 }