Java Doc for Command.java in  » Database-Client » Henplus » henplus » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database Client » Henplus » henplus 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


henplus.Command

All known Subclasses:   henplus.AbstractCommand,
Command
public interface Command (Code)
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...


version:
   $Revision: 1.10 $
author:
   Henner Zeller


Field Summary
final public static  intEXEC_FAILED
     constant returned by the Command.execute(SQLSession,String,String) if the command could not be executed because of some problem, that is not a syntax error.
final public static  intSUCCESS
     constant returned by the Command.execute(SQLSession,String,String) method, if everything went fine.
final public static  intSYNTAX_ERROR
     constant returned by the Command.execute(SQLSession,String,String) if the command could not be executed because of an syntax error.


Method Summary
 Iteratorcomplete(CommandDispatcher disp, String partialCommand, String lastWord)
     Returns a list of strings that are possible at this stage.
 intexecute(SQLSession session, String command, String parameters)
     execute the command given.
 String[]getCommandList()
     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.
 StringgetLongDescription(String cmd)
     returns a longer string describing this action.
 StringgetShortDescription()
     return a short string describing the purpose of the commands handled by this Command-implementation.
 StringgetSynopsis(String cmd)
     retuns a synopsis-string.
public  voidhandleCommandline(CommandLine line)
     After parsing the parameters, this method is called. there can be some default options left.
 booleanisComplete(String 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.

 booleanparticipateInCommandCompletion()
     returns 'false', if the commands supported by this Commands should not be part of the toplevel command completion.
public  voidregisterOptions(Options r)
     This method is called before parsing the commandline.
 booleanrequiresValidSession(String cmd)
     returns true, if this command requires a valid SQLSession, i.e.
public  voidsetOptions(Options options)
     Options are set, after the commandline has been parsed.
 voidshutdown()
     shutdown this command.

Field Detail
EXEC_FAILED
final public static int EXEC_FAILED(Code)
constant returned by the Command.execute(SQLSession,String,String) if the command could not be executed because of some problem, that is not a syntax error.



SUCCESS
final public static int SUCCESS(Code)
constant returned by the Command.execute(SQLSession,String,String) method, if everything went fine.



SYNTAX_ERROR
final public static int SYNTAX_ERROR(Code)
constant returned by the Command.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.





Method Detail
complete
Iterator complete(CommandDispatcher disp, String partialCommand, String lastWord)(Code)
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.
Parameters:
  disp - the CommandDispatcher - you might want to accessother values through it.
Parameters:
  partialCommand - The command typed so far
Parameters:
  lastWord - the last word returned by readline.



execute
int execute(SQLSession session, String command, String parameters)(Code)
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.
Parameters:
  command - the command as string.
Parameters:
  parameters - the rest parameters following the command. one of SUCCESS, SYNTAX_ERROR, EXEC_FAILED to indicatethe exit status of this command. On SYNTAX_ERROR, theCommandDispatcher displays a synopsis if available.



getCommandList
String[] getCommandList()(Code)
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.



getLongDescription
String getLongDescription(String cmd)(Code)
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.
Parameters:
  cmd - The command the long description is asked for. Thisis one of the possible commands returned by Command.getCommandList().



getShortDescription
String getShortDescription()(Code)
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.



getSynopsis
String getSynopsis(String cmd)(Code)
retuns a synopsis-string. The synopsis string returned should follow the following conventions:
  • expected parameters are described with angle brackets like in export-xml <table> <filename>
  • optional parameters are described with square brackets like in 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.
Parameters:
  cmd - the command the synopsis is for. This is one of the possiblecommands returned by Command.getCommandList().




handleCommandline
public void handleCommandline(CommandLine line)(Code)
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!
Parameters:
  line - TODO



isComplete
boolean isComplete(String command)(Code)
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.

  • 'select * from foobar' is not complete after a return, since we can expect a where clause. If it has a semicolon at the end, we know, that is is complete. So newline is not a delimiter while ';' is (return command.endsWith(";")).
  • definitions of stored procedures are even more complicated: it depends on the syntax whether a semicolon is part of the command or can be regarded as delimiter. Here, neither ';' nor newline can be regarded as delimiter per-se. Only the Command implementation can decide upon this. In Oracle, a single '/' on one line is used to denote this command-complete.
Note, this method should only apply a very lazy syntax check so it does not get confused and uses too much cycles unecessarily..
Parameters:
  command - the partial command read so far given to decide bythe command whether it is complete or not.



participateInCommandCompletion
boolean participateInCommandCompletion()(Code)
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'.



registerOptions
public void registerOptions(Options r)(Code)
This method is called before parsing the commandline. You can register command-specific options here.
Parameters:
  r -



requiresValidSession
boolean requiresValidSession(String cmd)(Code)
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.
Parameters:
  cmd - the subcommand this is requested for; one of thecommands returned by Command.getCommandList().



setOptions
public void setOptions(Options options)(Code)
Options are set, after the commandline has been parsed.
Parameters:
  options -



shutdown
void shutdown()(Code)
shutdown this command. This is called on exit of the CommandDispatcher and allows you to do some cleanup (close connections, flush files..)



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.