Source Code Cross Referenced for CommandHandler.java in  » Database-Client » SQLMinus » isql » 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 » SQLMinus » isql 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Author: rahul_kumar $
003:         * $Id: CommandHandler.java,v 1.1 2004/02/01 07:48:22 rahul_kumar Exp rahul $
004:         * This is free software, as software should be; you can redistribute 
005:         * it and/or modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2.1 of the License, or (at your option) any later version.
008:
009:         * See LICENSE.txt for the full license covering this software/program/code.
010:         */
011:
012:        package isql;
013:
014:        import java.util.*;
015:
016:        /**
017:         * Class documentation.
018:         * @author rahul kumar <rahul_kumar@yahoo.com>
019:         * @see XXX
020:         */
021:
022:        public class CommandHandler {
023:
024:            /** ctor/constructor.
025:             */
026:            public CommandHandler(SQLForm form) {
027:                _form = form;
028:                commandMap = new TreeMap();
029:                commands = Commands.getCommands();
030:            }
031:
032:            /** register the given command, by putting it in the command map
033:             * along with its command list.
034:             */
035:            public void register(Command com) {
036:                // fetch the string for given command and then put in map.
037:                String commandlist[] = com.getCommandList();
038:                for (int i = 0; i < commandlist.length; i++) {
039:                    commandMap.put(commandlist[i], com);
040:                }
041:            }
042:
043:            /** register all the commands in the commands array.
044:             */
045:            public void registerAllCommands() {
046:                for (int i = 0; i < commands.length; i++) {
047:                    register(commands[i]);
048:                }
049:            }
050:
051:            /** execute the given command.
052:             * fetches the command object from the map, and calls execute()
053:             * passing the SQLForm object.
054:             */
055:            public void execute(String command, String line) {
056:                Command com = getCommandFor(command);
057:                if (com == null) {
058:                    String serr = ("No command class was setup to handle this command. ["
059:                            + command + "]");
060:                    System.err.println(serr);
061:                    _form.popup(serr);
062:                    return;
063:                }
064:                com.execute(_form, command, line);
065:            }
066:
067:            /** returns the command object for a key.
068:             * required by help() in MetadataCommand also.
069:             */
070:            public Command getCommandFor(String key) {
071:                Command com = (Command) commandMap.get(key);
072:                // hack for default command - which handles all else.
073:                if (com == null) {
074:                    com = (Command) commandMap.get("");
075:                }
076:                return com;
077:
078:            }
079:
080:            /** returns commands.
081:             * used by MetadataCommand help().
082:             */
083:            public Command[] getCommands() {
084:                return commands;
085:            }
086:
087:            ////// START INSTANCE VARIABLES //////
088:
089:            /** a map of strings and command objects. */
090:            Map /*<String><Command>*/commandMap;
091:            /** array of commands */
092:            Command[] commands;
093:            /** instance of form object
094:             */
095:            SQLForm _form;
096:
097:            ////// START CONSTANTS AND CLASS LEVEL VARIABLES  //////
098:            static final String P = "CommandHandler"; // used in exception strings
099:
100:        } // end of class
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.