01: /*
02: * $Author$
03: * $Id$
04: * This is free software, as software should be; you can redistribute
05: * it and/or modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08:
09: * See LICENSE.txt for the full license covering this software/program/code.
10: */
11:
12: package isql.commands;
13:
14: import isql.Command;
15: import util.PerlWrapper;
16: import isql.*;
17: import util.*;
18: import javax.swing.JTextArea;
19: import javax.swing.table.TableModel;
20: import java.awt.Font;
21: import java.util.*;
22:
23: /**
24: * The command object associated with the reflect command, used to
25: * allows us to see fields and methods of metadata.
26: "reflect java.sql.DatabaseMetaData" allows us to see fields and
27: methods of the meta data. It even executes all methods that
28: dont require any parameters and prints the results.
29: However, this doesnt seem to work
30: on Oracle, and you need to explicitly invoke a method.
31:
32: "reflect ResultSet"
33: You can even say "reflect java.awt.Font"
34: * @author rahul kumar <rahul_kumar@yahoo.com>
35: * @see XXX
36: */
37:
38: public class ReflectCommand implements Command {
39:
40: /** ctor/constructor.
41: */
42: public ReflectCommand() {
43: }
44:
45: public String[] getCommandList() {
46: return commands;
47: }
48:
49: public void execute(SQLForm form, String command, String SQLString) {
50: _form = form;
51: SQLTabbedPane tp = _form.tp;
52: SQLJDBC myjdbc = _form.myjdbc;
53:
54: String cname = SQLString.substring(8).trim();
55: String[] ares = ReflectUtils.getClassFields(cname);
56: if (ares != null && ares.length != 0)
57: tp.appendOutputArea('\n' + ArrayUtil.join(ares, '\n'));
58: if (cname.indexOf("DatabaseMetaData") != -1) {
59: ares = ReflectUtils.getClassMethods(myjdbc.getDma(), cname);
60: // Oracle doesnt return answer ...
61: if (ares == null || ares.length == 0) {
62: System.err
63: .println("746:This database returned null on getClassMethods, trying without method calls..");
64: ares = ReflectUtils.getClassMethods(cname);
65: }
66: } else
67: ares = ReflectUtils.getClassMethods(cname);
68: tp.appendOutputArea('\n' + cname);
69: tp.appendOutputArea('\n' + ArrayUtil.join(ares, '\n'));
70: tp.makeOutputAreaVisible();
71:
72: }
73:
74: public String getUsage(String s) {
75: return usage;
76: }
77:
78: String commands[] = { "reflect" };
79: SQLForm _form;
80:
81: final String usage = "reflect <classname>";
82:
83: ////// START INSTANCE VARIABLES //////
84:
85: ////// START CONSTANTS AND CLASS LEVEL VARIABLES //////
86: static final String P = "ReflectCommand"; // used in exception strings
87:
88: } // end of class
|