henplus.commands
Class ConnectCommand

java.lang.Object
  extended by henplus.AbstractCommand
      extended by henplus.commands.ConnectCommand
All Implemented Interfaces:
Command

public class ConnectCommand
extends AbstractCommand

document me.


Field Summary
 
Fields inherited from interface henplus.Command
EXEC_FAILED, SUCCESS, SYNTAX_ERROR
 
Constructor Summary
ConnectCommand(HenPlus henplus, SessionManager sessionManager)
           
 
Method Summary
 Iterator complete(CommandDispatcher disp, String partialCommand, String lastWord)
          complete session names.
 int execute(SQLSession currentSession, String cmd, String param)
          execute the command given.
 String[] getCommandList()
          returns the command-strings this command can handle.
 String getLongDescription(String cmd)
          returns a longer string describing this action.
 String getShortDescription()
          return a descriptive string.
 String getSynopsis(String cmd)
          retuns a synopsis-string.
 void handleCommandline(CommandLine line)
          After parsing the parameters, this method is called.
 void registerOptions(Options r)
          Override this method if you want to register command-specific options
 boolean requiresValidSession(String cmd)
          we can connect, even if we don't have a running connection.
 void shutdown()
          shutdown this command.
 
Methods inherited from class henplus.AbstractCommand
argumentCount, getOption, getOptions, isComplete, participateInCommandCompletion, setOptions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectCommand

public ConnectCommand(HenPlus henplus,
                      SessionManager sessionManager)
Method Detail

getCommandList

public String[] getCommandList()
returns the command-strings this command can handle.


handleCommandline

public void handleCommandline(CommandLine line)
Description copied from interface: Command
After parsing the parameters, this method is called. there can be some default options left. These are set to the commands through this method. This is only for compatibility with the old commandline options, please use named options only!

Specified by:
handleCommandline in interface Command
Overrides:
handleCommandline in class AbstractCommand
Parameters:
line - TODO

registerOptions

public void registerOptions(Options r)
Description copied from class: AbstractCommand
Override this method if you want to register command-specific options

Specified by:
registerOptions in interface Command
Overrides:
registerOptions in class AbstractCommand

shutdown

public void shutdown()
Description copied from interface: Command
shutdown this command. This is called on exit of the CommandDispatcher and allows you to do some cleanup (close connections, flush files..)

Specified by:
shutdown in interface Command
Overrides:
shutdown in class AbstractCommand

requiresValidSession

public boolean requiresValidSession(String cmd)
we can connect, even if we don't have a running connection.

Specified by:
requiresValidSession in interface Command
Overrides:
requiresValidSession in class AbstractCommand
Parameters:
cmd - the subcommand this is requested for; one of the commands returned by Command.getCommandList().

complete

public Iterator complete(CommandDispatcher disp,
                         String partialCommand,
                         String lastWord)
complete session names. But not the session we are currently in, since we don't want to switch to our own session, right ?

Specified by:
complete in interface Command
Overrides:
complete in class AbstractCommand
Parameters:
disp - the CommandDispatcher - you might want to access other values through it.
partialCommand - The command typed so far
lastWord - the last word returned by readline.

execute

public int execute(SQLSession currentSession,
                   String cmd,
                   String param)
execute the command given.

Parameters:
currentSession - the SQLsession this command is executed from.
cmd - the command as string.
param - the rest parameters following the command.
Returns:
one of SUCCESS, SYNTAX_ERROR, EXEC_FAILED to indicate the exit status of this command. On SYNTAX_ERROR, the CommandDispatcher displays a synopsis if available.

getShortDescription

public String getShortDescription()
return a descriptive string.

Specified by:
getShortDescription in interface Command
Overrides:
getShortDescription in class AbstractCommand

getSynopsis

public String getSynopsis(String cmd)
Description copied from interface: Command
retuns a synopsis-string. The synopsis string returned should follow the following conventions:

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.

Specified by:
getSynopsis in interface Command
Overrides:
getSynopsis in class AbstractCommand
Parameters:
cmd - the command the synopsis is for. This is one of the possible commands returned by Command.getCommandList().

getLongDescription

public String getLongDescription(String cmd)
Description copied from interface: Command
returns a longer string describing this action. This should return a String describing details of the given command. This String should start with a TAB-character in each new line (the first line is a new line). The last line should not end with newline.

Specified by:
getLongDescription in interface Command
Overrides:
getLongDescription in class AbstractCommand
Parameters:
cmd - The command the long description is asked for. This is one of the possible commands returned by Command.getCommandList().


? 1997..2006 Henner Zeller