henplus.plugins.tablediff
Class TableDiffCommand

java.lang.Object
  extended by henplus.AbstractCommand
      extended by henplus.plugins.tablediff.TableDiffCommand
All Implemented Interfaces:
Command

public final class TableDiffCommand
extends AbstractCommand


Field Summary
protected static String _command
           
protected static String COMMAND_DELIMITER
           
protected static String OPTION_SINGLE_DB
           
 
Fields inherited from interface henplus.Command
EXEC_FAILED, SUCCESS, SYNTAX_ERROR
 
Constructor Summary
TableDiffCommand()
           
 
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.
 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.
 boolean requiresValidSession(String cmd)
          returns true, if this command requires a valid SQLSession, i.e.
 void shutdown()
          shutdown this command.
 
Methods inherited from class henplus.AbstractCommand
argumentCount, getOption, getOptions, handleCommandline, registerOptions, setOptions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_command

protected static final String _command
See Also:
Constant Field Values

COMMAND_DELIMITER

protected static final String COMMAND_DELIMITER
See Also:
Constant Field Values

OPTION_SINGLE_DB

protected static final String OPTION_SINGLE_DB
See Also:
Constant Field Values
Constructor Detail

TableDiffCommand

public TableDiffCommand()
Method Detail

getCommandList

public String[] getCommandList()
Description copied from interface: Command
returns the prefices of all command-strings this command can handle. The special prefix is the empty string that matches anything that is not handled by all other commands. It is used in the SQLCommand.


participateInCommandCompletion

public boolean participateInCommandCompletion()
Description copied from interface: Command
returns 'false', if the commands supported by this Commands should not be part of the toplevel command completion. So if the user presses TAB on an empty string to get the full list of possible commands, this command should not show up. In HenPlus, this returns 'false' for the SQL-commands ('select', 'update', 'drop' ..), since this would clobber the toplevel list of available commands. If unsure, return 'true'.

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

execute

public int execute(SQLSession session,
                   String command,
                   String parameters)
Description copied from interface: Command
execute the command given. The command is given completely without the final delimiter (which would be newline or semicolon). Before this method is called, the CommandDispatcher checks with the Command.isComplete(String) method, if this command is complete.

Parameters:
session - the SQLsession this command is executed from.
command - the command as string.
parameters - 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.

complete

public Iterator complete(CommandDispatcher disp,
                         String partialCommand,
                         String lastWord)
Description copied from interface: Command
Returns a list of strings that are possible at this stage. Used for the readline-completion in interactive mode. Based on the partial command and the lastWord you have to determine the words that are available at this stage. Return 'null', if you don't know a possible completion.

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.

isComplete

public boolean isComplete(String command)
Description copied from interface: Command
returns, whether the command is complete.

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.

Note, this method should only apply a very lazy syntax check so it does not get confused and uses too much cycles unecessarily..

Specified by:
isComplete in interface Command
Overrides:
isComplete in class AbstractCommand
Parameters:
command - the partial command read so far given to decide by the command whether it is complete or not.

requiresValidSession

public boolean requiresValidSession(String cmd)
Description copied from interface: Command
returns true, if this command requires a valid SQLSession, i.e. if the Command.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.

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().

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

getShortDescription

public String getShortDescription()
Description copied from interface: Command
return a short string describing the purpose of the commands handled by this Command-implementation. This is the string listed in the bare 'help' overview (like 'describe a database object') Should contain no newline, no leading spaces.

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