- All Known Implementing Classes:
AbstractCommand
,AbstractRandomDecisionCommand
,CmdAttack
,CmdBack
,CmdClear
,CmdDeleteGame
,CmdDodge
,CmdDrop
,CmdEquip
,CmdFight
,CmdHelp
,CmdListGames
,CmdLoadGame
,CmdLook
,CmdMove
,CmdNewGame
,CmdPick
,CmdRun
,CmdSaveGame
,CmdShow
,CmdUse
,CmdWai
,DummyCmd
public interface Command
Interface for command.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
Executes the command.getArgs()
Gets a copy of the argument list.Gets command context.Returns command stdin.Get a list of all the available argument for this command (necessary for command prediction)Gets current stdout writer.void
kill()
Requests command termination.void
Sets command arguments.void
setContext
(ApplicationContext context) Sets command context.void
setInputStream
(InputStream inputStream) Sets command stdin.void
Sets stdout writer for command.
-
Method Details
-
getArgs
Gets a copy of the argument list.- Returns:
- A copy of the argument list.
-
getPossibleArgs
Get a list of all the available argument for this command (necessary for command prediction)- Returns:
- ArrayList with all the possible arguments
- Throws:
GameStorageException
- If errors occur while fetching game data from the storage.
-
setArgs
Sets command arguments.- Parameters:
args
- Arguments.
-
getContext
ApplicationContext getContext()Gets command context.- Returns:
- Application context.
-
getWriter
Writer getWriter()Gets current stdout writer.- Returns:
- Stdout writer.
-
getInputStream
InputStream getInputStream()Returns command stdin.- Returns:
- Input stream.
-
setContext
Sets command context.- Parameters:
context
- Application context.
-
setWriter
Sets stdout writer for command.- Parameters:
out
- Output writer.
-
setInputStream
Sets command stdin.- Parameters:
inputStream
- Input stream.
-
execute
Executes the command.- Throws:
InterruptedException
- Thrown if the command is interrupted (e.g. when kill is well implemented).
-
kill
void kill()Requests command termination. This ONLY asks the command to terminate, but termination depends on the correct implementation of the command. If the command was executing then it will throw InterruptedException.
-