Source Code Cross Referenced for GTSQLTypeInfoDataSource.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.GTSQLTypeInfoDataSource  23 Mar 2002
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 java.util.ArrayList;
026:        import com.mckoi.util.BigNumber;
027:        import com.mckoi.database.global.SQLTypes;
028:
029:        /**
030:         * A GTDataSource that models all SQL types that are available.
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:        public class GTSQLTypeInfoDataSource extends GTDataSource {
039:
040:            /**
041:             * The DatabaseConnection object.  Currently this is not used, but it may
042:             * be needed in the future if user-defined SQL types are supported.
043:             */
044:            private DatabaseConnection database;
045:
046:            /**
047:             * The list of info keys/values in this object.
048:             */
049:            private ArrayList key_value_pairs;
050:
051:            /**
052:             * Constant for type_nullable types.
053:             */
054:            private static final BigNumber TYPE_NULLABLE = BigNumber
055:                    .fromInt(java.sql.DatabaseMetaData.typeNullable);
056:
057:            /**
058:             * Constructor.
059:             */
060:            public GTSQLTypeInfoDataSource(DatabaseConnection connection) {
061:                super (connection.getSystem());
062:                this .database = connection;
063:                this .key_value_pairs = new ArrayList();
064:            }
065:
066:            /**
067:             * Adds a type description.
068:             */
069:            private void addType(String name, int type, int precision,
070:                    String prefix, String suffix, String oops,
071:                    boolean searchable) {
072:                key_value_pairs.add(name);
073:                key_value_pairs.add(BigNumber.fromLong(type));
074:                key_value_pairs.add(BigNumber.fromLong(precision));
075:                key_value_pairs.add(prefix);
076:                key_value_pairs.add(suffix);
077:                key_value_pairs.add(searchable ? BigNumber.fromLong(3)
078:                        : BigNumber.fromLong(0));
079:            }
080:
081:            /**
082:             * Initialize the data source.
083:             */
084:            public GTSQLTypeInfoDataSource init() {
085:
086:                addType("BIT", SQLTypes.BIT, 1, null, null, null, true);
087:                addType("BOOLEAN", SQLTypes.BIT, 1, null, null, null, true);
088:                addType("TINYINT", SQLTypes.TINYINT, 9, null, null, null, true);
089:                addType("SMALLINT", SQLTypes.SMALLINT, 9, null, null, null,
090:                        true);
091:                addType("INTEGER", SQLTypes.INTEGER, 9, null, null, null, true);
092:                addType("BIGINT", SQLTypes.BIGINT, 9, null, null, null, true);
093:                addType("FLOAT", SQLTypes.FLOAT, 9, null, null, null, true);
094:                addType("REAL", SQLTypes.REAL, 9, null, null, null, true);
095:                addType("DOUBLE", SQLTypes.DOUBLE, 9, null, null, null, true);
096:                addType("NUMERIC", SQLTypes.NUMERIC, 9, null, null, null, true);
097:                addType("DECIMAL", SQLTypes.DECIMAL, 9, null, null, null, true);
098:                addType("CHAR", SQLTypes.CHAR, 9, "'", "'", null, true);
099:                addType("VARCHAR", SQLTypes.VARCHAR, 9, "'", "'", null, true);
100:                addType("LONGVARCHAR", SQLTypes.LONGVARCHAR, 9, "'", "'", null,
101:                        true);
102:                addType("DATE", SQLTypes.DATE, 9, null, null, null, true);
103:                addType("TIME", SQLTypes.TIME, 9, null, null, null, true);
104:                addType("TIMESTAMP", SQLTypes.TIMESTAMP, 9, null, null, null,
105:                        true);
106:                addType("BINARY", SQLTypes.BINARY, 9, null, null, null, false);
107:                addType("VARBINARY", SQLTypes.VARBINARY, 9, null, null, null,
108:                        false);
109:                addType("LONGVARBINARY", SQLTypes.LONGVARBINARY, 9, null, null,
110:                        null, false);
111:                addType("JAVA_OBJECT", SQLTypes.JAVA_OBJECT, 9, null, null,
112:                        null, false);
113:
114:                return this ;
115:            }
116:
117:            // ---------- Implemented from GTDataSource ----------
118:
119:            public DataTableDef getDataTableDef() {
120:                return DEF_DATA_TABLE_DEF;
121:            }
122:
123:            public int getRowCount() {
124:                return key_value_pairs.size() / 6;
125:            }
126:
127:            public TObject getCellContents(final int column, final int row) {
128:                int i = (row * 6);
129:                switch (column) {
130:                case 0: // type_name
131:                    return columnValue(column, (String) key_value_pairs.get(i));
132:                case 1: // data_type
133:                    return columnValue(column, (BigNumber) key_value_pairs
134:                            .get(i + 1));
135:                case 2: // precision
136:                    return columnValue(column, (BigNumber) key_value_pairs
137:                            .get(i + 2));
138:                case 3: // literal_prefix
139:                    return columnValue(column, (String) key_value_pairs
140:                            .get(i + 3));
141:                case 4: // literal_suffix
142:                    return columnValue(column, (String) key_value_pairs
143:                            .get(i + 4));
144:                case 5: // create_params
145:                    return columnValue(column, null);
146:                case 6: // nullable
147:                    return columnValue(column, TYPE_NULLABLE);
148:                case 7: // case_sensitive
149:                    return columnValue(column, Boolean.TRUE);
150:                case 8: // searchable
151:                    return columnValue(column, (BigNumber) key_value_pairs
152:                            .get(i + 5));
153:                case 9: // unsigned_attribute
154:                    return columnValue(column, Boolean.FALSE);
155:                case 10: // fixed_prec_scale
156:                    return columnValue(column, Boolean.FALSE);
157:                case 11: // auto_increment
158:                    return columnValue(column, Boolean.FALSE);
159:                case 12: // local_type_name
160:                    return columnValue(column, null);
161:                case 13: // minimum_scale
162:                    return columnValue(column, BigNumber.fromLong(0));
163:                case 14: // maximum_scale
164:                    return columnValue(column, BigNumber.fromLong(10000000));
165:                case 15: // sql_data_type
166:                    return columnValue(column, null);
167:                case 16: // sql_datetype_sub
168:                    return columnValue(column, null);
169:                case 17: // num_prec_radix
170:                    return columnValue(column, BigNumber.fromLong(10));
171:                default:
172:                    throw new Error("Column out of bounds.");
173:                }
174:            }
175:
176:            // ---------- Overwritten from GTDataSource ----------
177:
178:            public void dispose() {
179:                super .dispose();
180:                key_value_pairs = null;
181:                database = null;
182:            }
183:
184:            // ---------- Static ----------
185:
186:            /**
187:             * The data table def that describes this table of data source.
188:             */
189:            static final DataTableDef DEF_DATA_TABLE_DEF;
190:
191:            static {
192:
193:                DataTableDef def = new DataTableDef();
194:                def.setTableName(new TableName(Database.SYSTEM_SCHEMA,
195:                        "sUSRSQLTypeInfo"));
196:
197:                // Add column definitions
198:                def.addColumn(stringColumn("TYPE_NAME"));
199:                def.addColumn(numericColumn("DATA_TYPE"));
200:                def.addColumn(numericColumn("PRECISION"));
201:                def.addColumn(stringColumn("LITERAL_PREFIX"));
202:                def.addColumn(stringColumn("LITERAL_SUFFIX"));
203:                def.addColumn(stringColumn("CREATE_PARAMS"));
204:                def.addColumn(numericColumn("NULLABLE"));
205:                def.addColumn(booleanColumn("CASE_SENSITIVE"));
206:                def.addColumn(numericColumn("SEARCHABLE"));
207:                def.addColumn(booleanColumn("UNSIGNED_ATTRIBUTE"));
208:                def.addColumn(booleanColumn("FIXED_PREC_SCALE"));
209:                def.addColumn(booleanColumn("AUTO_INCREMENT"));
210:                def.addColumn(stringColumn("LOCAL_TYPE_NAME"));
211:                def.addColumn(numericColumn("MINIMUM_SCALE"));
212:                def.addColumn(numericColumn("MAXIMUM_SCALE"));
213:                def.addColumn(stringColumn("SQL_DATA_TYPE"));
214:                def.addColumn(stringColumn("SQL_DATETIME_SUB"));
215:                def.addColumn(numericColumn("NUM_PREC_RADIX"));
216:
217:                // Set to immutable
218:                def.setImmutable();
219:
220:                DEF_DATA_TABLE_DEF = def;
221:
222:            }
223:
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.