|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Command
Interface to be implemented for user level commands.
The CommandDispatcher and the HelpCommand operate on this interface. This interface needs to be implemented by your own Commands or Plugins that should be supported by HenPlus. If the documenation given here is not enough (though I hope it is), just read some of the implementations given in henplus.commands.
If you are writing Plugins, consider extending the
AbstractCommand
as it provides a default implementation
and you are immune to NoSuchMethodErrors if this interface changes
but not yet your plugin...
Field Summary | |
---|---|
static int |
EXEC_FAILED
constant returned by the execute(SQLSession,String,String)
if the command could not be executed because of some problem, that
is not a syntax error. |
static int |
SUCCESS
constant returned by the execute(SQLSession,String,String)
method, if everything went fine. |
static int |
SYNTAX_ERROR
constant returned by the execute(SQLSession,String,String)
if the command could not be executed because of an syntax error. |
Method Summary | |
---|---|
Iterator |
complete(CommandDispatcher disp,
String partialCommand,
String lastWord)
Returns a list of strings that are possible at this stage. |
int |
execute(SQLSession session,
String command,
String parameters)
execute the command given. |
String[] |
getCommandList()
returns the prefices of all command-strings this command can handle. |
String |
getLongDescription(String cmd)
returns a longer string describing this action. |
String |
getShortDescription()
return a short string describing the purpose of the commands handled by this Command-implementation. |
String |
getSynopsis(String cmd)
retuns a synopsis-string. |
void |
handleCommandline(CommandLine line)
After parsing the parameters, this method is called. |
boolean |
isComplete(String command)
returns, whether the command is complete. |
boolean |
participateInCommandCompletion()
returns 'false', if the commands supported by this Commands should not be part of the toplevel command completion. |
void |
registerOptions(Options r)
This method is called before parsing the commandline. |
boolean |
requiresValidSession(String cmd)
returns true, if this command requires a valid SQLSession, i.e. |
void |
setOptions(Options options)
Options are set, after the commandline has been parsed. |
void |
shutdown()
shutdown this command. |
Field Detail |
---|
static final int SUCCESS
execute(SQLSession,String,String)
method, if everything went fine.
static final int SYNTAX_ERROR
execute(SQLSession,String,String)
if the command could not be executed because of an syntax error.
In that case, the CommandDispatcher will display the synopsis of
that command.
static final int EXEC_FAILED
execute(SQLSession,String,String)
if the command could not be executed because of some problem, that
is not a syntax error.
Method Detail |
---|
String[] getCommandList()
boolean participateInCommandCompletion()
int execute(SQLSession session, String command, String parameters)
isComplete(String)
method, if this command is complete.
session
- the SQLsession this command is executed from.command
- the command as string.parameters
- the rest parameters following the command.
Iterator complete(CommandDispatcher disp, String partialCommand, String lastWord)
disp
- the CommandDispatcher - you might want to access
other values through it.partialCommand
- The command typed so farlastWord
- the last word returned by readline.boolean isComplete(String command)
This method is called, whenever the input encounters a newline or a semicolon to decide if this separator is to separate different commands or if it is part of the command itself.
The delimiter (newline or semicolon) is contained (at the end)
in the String passed to this method. This
method returns false
, if the delimiter is part of the
command and will not be regarded as delimiter between commands -- the
reading part of the command dispatcher will go on reading characters
and not execute the command.
This method will return true for most simple commands like 'help'. For commands that have a more complicated syntax, this might not be true.
command
- the partial command read so far given to decide by
the command whether it is complete or not.boolean requiresValidSession(String cmd)
execute(SQLSession,String,String)
method makes use of the
session (e.g. to get some Database connection) or not. Return 'true'
if unsure (you should be sure..). This is to thwart attempts to
execute a command without session.
cmd
- the subcommand this is requested for; one of the
commands returned by getCommandList()
.void shutdown()
String getShortDescription()
'describe a database object'
)
Should contain no newline, no leading spaces.
String getSynopsis(String cmd)
export-xml <table> <filename>
help [command]
Should contain no newline, no leading spaces. This synopsis is printed in the detailed help of a command or if the execute()-method returned a SYNTAX_ERROR.
cmd
- the command the synopsis is for. This is one of the possible
commands returned by getCommandList()
.String getLongDescription(String cmd)
cmd
- The command the long description is asked for. This
is one of the possible commands returned by
getCommandList()
.void setOptions(Options options)
options
- void registerOptions(Options r)
r
- void handleCommandline(CommandLine line)
line
- TODO
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |