Package commandManagers
Class Command
java.lang.Object
commandManagers.Command
- All Implemented Interfaces:
CommandInterface
- Direct Known Subclasses:
Add,AddIfMin,Clear,ExecuteScript,Exit,Help,History,Info,PrintDescending,PrintFieldDescendingMetersAboveSeaLevel,RemoveById,RemoveGreater,Save,Show,SumOfMetersAboveSeaLevel,UpdateId
Abstract class representing a command that can be executed in the program.
-
Constructor Summary
ConstructorsConstructorDescriptionCommand(boolean hasArgument) Constructs a new command with the specified argument requirement. -
Method Summary
Modifier and TypeMethodDescriptionabstract booleancheckArgument(Object inputArgument) Checks if the given inputArgument is valid for this command.abstract voidexecute()Executes command.Returns the argument for this command.abstract StringgetDescr()Base method for show command description.abstract StringgetName()Base method for show command namebooleanReturns whether this command requires an argument.voidsetArgument(String argument) Sets the argument for this command.
-
Constructor Details
-
Command
public Command(boolean hasArgument) Constructs a new command with the specified argument requirement.- Parameters:
hasArgument- a boolean indicating whether this command requires an argument or not.
-
-
Method Details
-
getName
Base method for show command name- Specified by:
getNamein interfaceCommandInterface- Returns:
- command name
-
getDescr
Base method for show command description.- Specified by:
getDescrin interfaceCommandInterface- Returns:
- command description
-
execute
Executes command.- Specified by:
executein interfaceCommandInterface- Throws:
BuildObjectException
-
checkArgument
Checks if the given inputArgument is valid for this command.- Specified by:
checkArgumentin interfaceCommandInterface- Parameters:
inputArgument- the argument to check.- Returns:
- true if the argument is valid, false otherwise.
-
isHasArgument
public boolean isHasArgument()Returns whether this command requires an argument.- Returns:
- true if this command requires an argument, false otherwise.
-
getArgument
Returns the argument for this command.- Returns:
- the argument for this command.
-
setArgument
Sets the argument for this command.- Parameters:
argument- the argument to set.
-