Source Code Cross Referenced for SystemColumnImpl.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » sql » catalog » 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 » db derby 10.2 » org.apache.derby.impl.sql.catalog 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.sql.catalog.SystemColumnImpl
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.impl.sql.catalog;
023:
024:        import java.sql.Types;
025:
026:        import org.apache.derby.iapi.sql.dictionary.SystemColumn;
027:        import org.apache.derby.iapi.error.StandardException;
028:        import org.apache.derby.iapi.types.DataTypeDescriptor;
029:        import org.apache.derby.iapi.types.DataValueDescriptor;
030:        import org.apache.derby.iapi.types.DataValueFactory;
031:        import org.apache.derby.iapi.types.TypeId;
032:
033:        /**
034:         * Implements the description of a column in a system table.
035:         *
036:         *
037:         * @version 0.1
038:         * @author Rick Hillegas
039:         */
040:
041:        class SystemColumnImpl implements  SystemColumn {
042:            private final String name;
043:
044:            /**
045:             * Fully described type of the column.
046:             */
047:            private final DataTypeDescriptor type;
048:
049:            /**
050:             * Create a system column for a builtin type.
051:             * 
052:             * @param name
053:             *            name of column
054:             * @param jdbcTypeId
055:             *            JDBC type id from java.sql.Types
056:             * @param nullability
057:             *            Whether or not column accepts nulls.
058:             */
059:            static SystemColumn getColumn(String name, int jdbcTypeId,
060:                    boolean nullability) {
061:                return new SystemColumnImpl(name, DataTypeDescriptor
062:                        .getBuiltInDataTypeDescriptor(jdbcTypeId, nullability));
063:            }
064:
065:            /**
066:             * Create a system column for a builtin type.
067:             * 
068:             * @param name
069:             *            name of column
070:             * @param jdbcTypeId
071:             *            JDBC type id from java.sql.Types
072:             * @param nullability
073:             *            Whether or not column accepts nulls.
074:             */
075:            static SystemColumn getColumn(String name, int jdbcTypeId,
076:                    boolean nullability, int maxLength) {
077:                return new SystemColumnImpl(name, DataTypeDescriptor
078:                        .getBuiltInDataTypeDescriptor(jdbcTypeId, nullability,
079:                                maxLength));
080:            }
081:
082:            /**
083:             * Create a system column for an identifer with consistent type of
084:             * VARCHAR(128)
085:             * 
086:             * @param name
087:             *            Name of the column.
088:             * @param nullability
089:             *            Nullability of the column.
090:             * @return Object representing the column.
091:             */
092:            static SystemColumn getIdentifierColumn(String name,
093:                    boolean nullability) {
094:                return new SystemColumnImpl(name, DataTypeDescriptor
095:                        .getBuiltInDataTypeDescriptor(Types.VARCHAR,
096:                                nullability, 128));
097:            }
098:
099:            /**
100:             * Create a system column for a character representation of a UUID with
101:             * consistent type of CHAR(36)
102:             * 
103:             * @param name
104:             *            Name of the column.
105:             * @param nullability
106:             *            Nullability of the column.
107:             * @return Object representing the column.
108:             */
109:            static SystemColumn getUUIDColumn(String name, boolean nullability) {
110:                return new SystemColumnImpl(name, DataTypeDescriptor
111:                        .getBuiltInDataTypeDescriptor(Types.CHAR, nullability,
112:                                36));
113:            }
114:
115:            /**
116:             * Create a system column for a character representation of an indicator
117:             * column with consistent type of CHAR(1) NOT NULL
118:             * 
119:             * @param name
120:             *            Name of the column.
121:             * @return Object representing the column.
122:             */
123:            static SystemColumn getIndicatorColumn(String name) {
124:                return new SystemColumnImpl(name, DataTypeDescriptor
125:                        .getBuiltInDataTypeDescriptor(Types.CHAR, false, 1));
126:            }
127:
128:            /**
129:             * Create a system column for a java column.
130:             * 
131:             * @param name
132:             *            Name of the column.
133:             * @param javaClassName
134:             * @param nullability
135:             *            Nullability of the column.
136:             * @return Object representing the column.
137:             */
138:            static SystemColumn getJavaColumn(String name,
139:                    String javaClassName, boolean nullability) {
140:
141:                TypeId typeId = TypeId.getUserDefinedTypeId(javaClassName,
142:                        false);
143:
144:                DataTypeDescriptor dtd = new DataTypeDescriptor(typeId,
145:                        nullability);
146:                return new SystemColumnImpl(name, dtd);
147:            }
148:
149:            /**
150:             * Create a SystemColumnImpl representing the given name and type.
151:             */
152:            private SystemColumnImpl(String name, DataTypeDescriptor type) {
153:                this .name = name;
154:                this .type = type;
155:            }
156:
157:            /**
158:             * Constructor to create a description of a column in a system table.
159:             * 
160:             * @param name
161:             *            of column.
162:             * @param id
163:             *            of column.
164:             * @param nullability
165:             *            Whether or not column accepts nulls.
166:             * @param dataType
167:             *            Datatype of column.
168:             * @param maxLength
169:             *            Maximum length of data in column.
170:             */
171:            SystemColumnImpl(String name, int id, boolean nullability,
172:                    String dataType, boolean builtInType, int maxLength) {
173:                this .name = name;
174:
175:                TypeId typeId;
176:
177:                if (builtInType) {
178:                    typeId = TypeId.getBuiltInTypeId(dataType);
179:                } else {
180:
181:                    typeId = TypeId.getUserDefinedTypeId(dataType, false);
182:                }
183:
184:                this .type = new DataTypeDescriptor(typeId, 0, 0, nullability,
185:                        maxLength);
186:            }
187:
188:            SystemColumnImpl(String name, int id, int ignoreP, int ignoreS,
189:                    boolean nullability, String dataType, boolean builtInType,
190:                    int maxLength) {
191:                this (name, id, nullability, dataType, builtInType, maxLength);
192:            }
193:
194:            /**
195:             * Constructor to create a description of a column in a system table.
196:             * This constructor is used for SQL Identifiers (varchar 128).
197:             *
198:             *	@param	name of column.
199:             *	@param	id of column.
200:             *	@param	nullability Whether or not column accepts nulls.
201:             */
202:            SystemColumnImpl(String name, int id, boolean nullability) {
203:                this (name, id, nullability, "VARCHAR", true, 128);
204:            }
205:
206:            /**
207:             * Gets the name of this column.
208:             *
209:             * @return	The column name.
210:             */
211:            public String getName() {
212:                return name;
213:            }
214:
215:            /**
216:             * Return the type of this column.
217:             */
218:            public DataTypeDescriptor getType() {
219:                return type;
220:            }
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.