Source Code Cross Referenced for GTTableColumnsDataSource.java in  » Database-DBMS » mckoi » com » mckoi » database » 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 DBMS » mckoi » com.mckoi.database 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * com.mckoi.database.GTTableColumnsDataSource  27 Apr 2001
003:         *
004:         * Mckoi SQL Database ( http://www.mckoi.com/database )
005:         * Copyright (C) 2000, 2001, 2002  Diehl and Associates, Inc.
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * Version 2 as published by the Free Software Foundation.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License Version 2 for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * Version 2 along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         *
020:         * Change Log:
021:         * 
022:         * 
023:         */package com.mckoi.database;
024:
025:        import com.mckoi.util.BigNumber;
026:        import com.mckoi.database.global.SQLTypes;
027:
028:        /**
029:         * An implementation of MutableTableDataSource that presents information
030:         * about the columns of all tables in all schema.
031:         * <p>
032:         * NOTE: This is not designed to be a long kept object.  It must not last
033:         *   beyond the lifetime of a transaction.
034:         *
035:         * @author Tobias Downer
036:         */
037:
038:        final class GTTableColumnsDataSource extends GTDataSource {
039:
040:            /**
041:             * The transaction that is the view of this information.
042:             */
043:            private Transaction transaction;
044:
045:            /**
046:             * The list of all DataTableDef visible to the transaction.
047:             */
048:            private DataTableDef[] visible_tables;
049:
050:            /**
051:             * The number of rows in this table.
052:             */
053:            private int row_count;
054:
055:            /**
056:             * Constructor.
057:             */
058:            public GTTableColumnsDataSource(Transaction transaction) {
059:                super (transaction.getSystem());
060:                this .transaction = transaction;
061:            }
062:
063:            /**
064:             * Initialize the data source.
065:             */
066:            public GTTableColumnsDataSource init() {
067:                // All the tables
068:                TableName[] list = transaction.getTableList();
069:                visible_tables = new DataTableDef[list.length];
070:                row_count = 0;
071:                for (int i = 0; i < list.length; ++i) {
072:                    DataTableDef def = transaction.getDataTableDef(list[i]);
073:                    row_count += def.columnCount();
074:                    visible_tables[i] = def;
075:                }
076:                return this ;
077:            }
078:
079:            // ---------- Implemented from GTDataSource ----------
080:
081:            public DataTableDef getDataTableDef() {
082:                return DEF_DATA_TABLE_DEF;
083:            }
084:
085:            public int getRowCount() {
086:                return row_count;
087:            }
088:
089:            public TObject getCellContents(final int column, final int row) {
090:
091:                final int sz = visible_tables.length;
092:                int rs = 0;
093:                for (int n = 0; n < sz; ++n) {
094:                    final DataTableDef def = visible_tables[n];
095:                    final int b = rs;
096:                    rs += def.columnCount();
097:                    if (row >= b && row < rs) {
098:                        // This is the column that was requested,
099:                        int seq_no = row - b;
100:                        DataTableColumnDef col_def = def.columnAt(seq_no);
101:                        switch (column) {
102:                        case 0: // schema
103:                            return columnValue(column, def.getSchema());
104:                        case 1: // table
105:                            return columnValue(column, def.getName());
106:                        case 2: // column
107:                            return columnValue(column, col_def.getName());
108:                        case 3: // sql_type
109:                            return columnValue(column, BigNumber
110:                                    .fromLong(col_def.getSQLType()));
111:                        case 4: // type_desc
112:                            return columnValue(column, col_def
113:                                    .getSQLTypeString());
114:                        case 5: // size
115:                            return columnValue(column, BigNumber
116:                                    .fromLong(col_def.getSize()));
117:                        case 6: // scale
118:                            return columnValue(column, BigNumber
119:                                    .fromLong(col_def.getScale()));
120:                        case 7: // not_null
121:                            return columnValue(column, new Boolean(col_def
122:                                    .isNotNull()));
123:                        case 8: // default
124:                            return columnValue(column, col_def
125:                                    .getDefaultExpressionString());
126:                        case 9: // index_str
127:                            return columnValue(column, col_def.getIndexScheme());
128:                        case 10: // seq_no
129:                            return columnValue(column, BigNumber
130:                                    .fromLong(seq_no));
131:                        default:
132:                            throw new Error("Column out of bounds.");
133:                        }
134:                    }
135:
136:                } // for each visible table
137:
138:                throw new Error("Row out of bounds.");
139:            }
140:
141:            // ---------- Overwritten ----------
142:
143:            public void dispose() {
144:                super .dispose();
145:                visible_tables = null;
146:                transaction = null;
147:            }
148:
149:            // ---------- Static ----------
150:
151:            /**
152:             * The data table def that describes this table of data source.
153:             */
154:            static final DataTableDef DEF_DATA_TABLE_DEF;
155:
156:            static {
157:
158:                DataTableDef def = new DataTableDef();
159:                def.setTableName(new TableName(Database.SYSTEM_SCHEMA,
160:                        "sUSRTableColumns"));
161:
162:                // Add column definitions
163:                def.addColumn(stringColumn("schema"));
164:                def.addColumn(stringColumn("table"));
165:                def.addColumn(stringColumn("column"));
166:                def.addColumn(numericColumn("sql_type"));
167:                def.addColumn(stringColumn("type_desc"));
168:                def.addColumn(numericColumn("size"));
169:                def.addColumn(numericColumn("scale"));
170:                def.addColumn(booleanColumn("not_null"));
171:                def.addColumn(stringColumn("default"));
172:                def.addColumn(stringColumn("index_str"));
173:                def.addColumn(numericColumn("seq_no"));
174:
175:                // Set to immutable
176:                def.setImmutable();
177:
178:                DEF_DATA_TABLE_DEF = def;
179:
180:            }
181:
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.