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


001:        /*
002:         * $Author$
003:         * $Id$
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.commands;
013:
014:        import isql.Command;
015:        import util.PerlWrapper;
016:        import isql.*;
017:        import util.*;
018:        import javax.swing.*;
019:        import javax.swing.table.*;
020:        import java.awt.*;
021:        import java.util.*;
022:
023:        /**
024:         * The command object associated with our metadata, such as links for
025:         * tables, sort options etc.
026:         * I am wondering whether they should be separate classes, however,
027:         * would like them to be in one place.
028:         * @author rahul kumar <rahul_kumar@yahoo.com>
029:         * @see XXX
030:         */
031:
032:        public class MetadataCommand implements  Command {
033:
034:            /** ctor/constructor.
035:             */
036:            public MetadataCommand() {
037:            }
038:
039:            public String[] getCommandList() {
040:                return commands;
041:            }
042:
043:            public void execute(SQLForm form, String fword, String SQLString) {
044:                _form = form;
045:                SQLTabbedPane tp = _form.tp;
046:                //SQLJDBC myjdbc = _form.myjdbc;
047:
048:                Map htLinks = _form.getLinkMap();
049:                Map htMaster = _form.getMasterMap();
050:                Map htSorts = _form.getSortMap();
051:
052:                if (fword.equals("help")) {
053:                    _form.tp.appendOutputArea(help(fword, SQLString));
054:                    _form.tp.makeOutputAreaVisible();
055:                    return;
056:                }
057:                if (fword.equals("settings")) {
058:                    _form.tp.appendOutputArea(settings(fword, SQLString));
059:                    _form.tp.makeOutputAreaVisible();
060:                    return;
061:                }
062:                if (fword.equals("link")) {
063:                    String ts = SQLString.substring(5);
064:                    int pos1 = ts.indexOf(':');
065:                    int pos2 = ts.indexOf(':', pos1 + 1);
066:                    if (htLinks == null)
067:                        htLinks = new HashMap();
068:                    String tname = ts.substring(0, pos1) + '.';
069:                    String master = ts.substring(pos2 + 1);
070:                    if ("..".equals(tname))
071:                        tname = "";
072:                    htLinks.put(tname + ts.substring(pos1 + 1, pos2), master);
073:                    if (SQLForm.DEBUG)
074:                        System.out.print(" Master:" + master);
075:                    String p[] = ArrayUtil.split(master, ':');
076:                    String key = p[1];
077:                    if (htMaster == null)
078:                        htMaster = new HashMap();
079:                    htMaster.put(key, master);
080:                    System.out.print(" key:" + key);
081:                    return;
082:                }
083:                if (fword.equals("sort")) {
084:                    String ts = SQLString.substring(5);
085:                    if (htSorts == null)
086:                        htSorts = new HashMap();
087:                    int pos1 = ts.indexOf(':');
088:                    // put table name and then sort
089:                    // order
090:                    htSorts.put(ts.substring(0, pos1), ts.substring(pos1 + 1));
091:                    return;
092:                }
093:
094:            }
095:
096:            public String settings(String fword, String SQLString) {
097:                StringBuffer sb = new StringBuffer(128);
098:                Map params = _form.getParams();
099:                sb.append("Attributes:\n");
100:                sb = printMap(params, sb);
101:                sb.append("Links:\n");
102:                Map htLinks = _form.getLinkMap();
103:                sb = printMap(htLinks, sb);
104:                sb.append("Master:\n");
105:                Map htMaster = _form.getMasterMap();
106:                sb = printMap(htMaster, sb);
107:                Map htSorts = _form.getSortMap();
108:                sb.append("Sorts:\n");
109:                sb = printMap(htSorts, sb);
110:                sb.append("Filters:\n");
111:                sb = printMap(_form.getFilterMap(), sb);
112:
113:                sb.append("Abbreviations:\n");
114:                sb = printMap(_form.getAbbreviations(), sb);
115:                sb.append("Remembered Values:\n");
116:                sb = printMap(_form.getRemembered(), sb);
117:                return sb.toString();
118:
119:            }
120:
121:            private StringBuffer printMap(Map map, StringBuffer sb) {
122:                if (map == null) {
123:                    sb.append('\t').append("No values.");
124:                    return sb;
125:                }
126:                Iterator it = map.keySet().iterator();
127:                while (it.hasNext()) {
128:                    String key = (String) it.next();
129:                    Object value = (Object) map.get(key);
130:                    sb.append('\t').append(key).append(':').append(value)
131:                            .append('\n');
132:                }
133:                return sb;
134:            }
135:
136:            public String help(String fword, String SQLString) {
137:                if (fword.trim().equals(SQLString.trim())) {
138:                    //Command[] commands = Commands.getCommands();
139:                    Command[] commands = _form.getCommandHandler()
140:                            .getCommands();
141:                    StringBuffer sb = new StringBuffer(128);
142:
143:                    for (int i = 0; i < commands.length; i++) {
144:                        Command com = commands[i];
145:                        String[] commandlist = com.getCommandList();
146:                        for (int j = 0; j < commandlist.length; j++) {
147:                            String key = commandlist[j];
148:                            sb.append(key).append(":\n\t");
149:                            sb.append(com.getUsage(key)).append('\n');
150:                        }
151:                    }
152:                    return sb.toString();
153:                } else {
154:                    String w[] = ArrayUtil.split(SQLString, ' ');
155:                    String option = w[1];
156:                    Command com = _form.getCommandHandler().getCommandFor(
157:                            option);
158:                    if (com == null)
159:                        return "No command:" + option;
160:                    return com.getUsage(option);
161:                }
162:            } // help
163:
164:            public String getUsage(String s) {
165:                if (s.equals("sort"))
166:                    return "sort <table>:<sortorder>";
167:                if (s.equals("link"))
168:                    return "link <table>:<column>:<link table>:<link column>:<link condition>";
169:                if (s.equals("help"))
170:                    return "help ";
171:                if (s.equals("settings"))
172:                    return "settings ";
173:                return s + " not implemented";
174:
175:            }
176:
177:            String commands[] = { "link", "sort", "filter", "help", "settings" };
178:            SQLForm _form;
179:
180:            ////// START INSTANCE VARIABLES //////
181:
182:            ////// START CONSTANTS AND CLASS LEVEL VARIABLES  //////
183:            static final String P = "MetadataCommand"; // used in exception strings
184:
185:        } // 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.