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


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.sql.execute.ColumnInfo
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.execute;
023:
024:        import org.apache.derby.iapi.services.io.Formatable;
025:        import org.apache.derby.iapi.services.io.StoredFormatIds;
026:        import org.apache.derby.iapi.services.io.FormatIdUtil;
027:
028:        import org.apache.derby.iapi.error.StandardException;
029:
030:        import org.apache.derby.iapi.types.DataTypeDescriptor;
031:        import org.apache.derby.iapi.types.DataValueDescriptor;
032:
033:        import org.apache.derby.iapi.services.sanity.SanityManager;
034:
035:        import org.apache.derby.catalog.DefaultInfo;
036:        import org.apache.derby.catalog.UUID;
037:
038:        import org.apache.derby.iapi.services.io.FormatableHashtable;
039:        import org.apache.derby.iapi.services.io.FormatableIntHolder;
040:        import org.apache.derby.iapi.services.io.FormatableLongHolder;
041:
042:        import java.io.ObjectOutput;
043:        import java.io.ObjectInput;
044:        import java.io.IOException;
045:
046:        /**
047:         *	This is the Column descriptor that is passed from Compilation to Execution
048:         *	for CREATE TABLE statements.
049:         *
050:         *	@version 0.1
051:         *	@author Rick Hillegas
052:         */
053:
054:        public class ColumnInfo implements  Formatable {
055:            /********************************************************
056:             **
057:             **	This class implements Formatable. That means that it
058:             **	can write itself to and from a formatted stream. If
059:             **	you add more fields to this class, make sure that you
060:             **	also write/read them with the writeExternal()/readExternal()
061:             **	methods.
062:             **
063:             **	If, inbetween releases, you add more fields to this class,
064:             **	then you should bump the version number emitted by the getTypeFormatId()
065:             **	method.
066:             **
067:             ********************************************************/
068:
069:            public int action;
070:            public String name;
071:            public DataTypeDescriptor dataType;
072:            public DefaultInfo defaultInfo;
073:            public DataValueDescriptor defaultValue;
074:            public UUID newDefaultUUID;
075:            public UUID oldDefaultUUID;
076:            // autoinc columns.
077:            public long autoincStart;
078:            public long autoincInc;
079:            //if this is an autoincrement column, then following variable will have CREATE or
080:            //MODIFY_COLUMN_DEFAULT_RESTART or MODIFY_COLUMN_DEFAULT_INCREMENT. Otherwise,
081:            //this variable will be set to -1.
082:            public long autoinc_create_or_modify_Start_Increment = -1;
083:
084:            //This indicates column is for CREATE TABLE
085:            public static final int CREATE = 0;
086:            public static final int DROP = 1;
087:            public static final int MODIFY_COLUMN_TYPE = 2;
088:            public static final int MODIFY_COLUMN_CONSTRAINT = 3;
089:            public static final int MODIFY_COLUMN_CONSTRAINT_NOT_NULL = 4;
090:            //This indicates column is for ALTER TABLE to change the start value of autoinc column 
091:            public static final int MODIFY_COLUMN_DEFAULT_RESTART = 5;
092:            //This indicates column is for ALTER TABLE to change the increment value of autoinc column 
093:            public static final int MODIFY_COLUMN_DEFAULT_INCREMENT = 6;
094:
095:            // CONSTRUCTORS
096:
097:            /**
098:             * Public niladic constructor. Needed for Formatable interface to work.
099:             *
100:             */
101:            public ColumnInfo() {
102:            }
103:
104:            /**
105:             *	Make one of these puppies.
106:             *
107:             *  @param name			Column name.
108:             *  @param dataType		Column type.
109:             *  @param defaultValue	Column default value.
110:             *  @param defaultInfo	Column default info.
111:             *  @param newDefaultUUID	New UUID for default.
112:             *  @param oldDefaultUUID	Old UUID for default.
113:             *	@param action		Action (create, modify default, etc.)
114:             * 	@param autoincStart Start of autoincrement values.
115:             *  @param autoincInc	Increment of autoincrement values-- if parameter
116:             *						is 0, it implies that this is not an autoincrement
117:             *						value.
118:             */
119:            public ColumnInfo(String name, DataTypeDescriptor dataType,
120:                    DataValueDescriptor defaultValue, DefaultInfo defaultInfo,
121:                    UUID newDefaultUUID, UUID oldDefaultUUID, int action,
122:                    long autoincStart, long autoincInc,
123:                    long autoinc_create_or_modify_Start_Increment) {
124:                this .name = name;
125:                this .dataType = dataType;
126:                this .defaultValue = defaultValue;
127:                this .defaultInfo = defaultInfo;
128:                this .newDefaultUUID = newDefaultUUID;
129:                this .oldDefaultUUID = oldDefaultUUID;
130:                this .action = action;
131:                this .autoincStart = autoincStart;
132:                this .autoincInc = autoincInc;
133:                this .autoinc_create_or_modify_Start_Increment = autoinc_create_or_modify_Start_Increment;
134:            }
135:
136:            // Formatable methods
137:
138:            /**
139:             * Read this object from a stream of stored objects.
140:             *
141:             * @param in read this.
142:             *
143:             * @exception IOException					thrown on error
144:             * @exception ClassNotFoundException		thrown on error
145:             */
146:            public void readExternal(ObjectInput in) throws IOException,
147:                    ClassNotFoundException {
148:
149:                FormatableLongHolder flh;
150:
151:                FormatableHashtable fh = (FormatableHashtable) in.readObject();
152:                name = (String) fh.get("name");
153:                dataType = (DataTypeDescriptor) fh.get("dataType");
154:                defaultValue = (DataValueDescriptor) fh.get("defaultValue");
155:                defaultInfo = (DefaultInfo) fh.get("defaultInfo");
156:                newDefaultUUID = (UUID) fh.get("newDefaultUUID");
157:                oldDefaultUUID = (UUID) fh.get("oldDefaultUUID");
158:                action = fh.getInt("action");
159:
160:                if (fh.get("autoincStart") != null) {
161:                    autoincStart = fh.getLong("autoincStart");
162:                    autoincInc = fh.getLong("autoincInc");
163:                } else {
164:                    autoincInc = autoincStart = 0;
165:                }
166:            }
167:
168:            /**
169:             * Write this object to a stream of stored objects.
170:             *
171:             * @param out write bytes here.
172:             *
173:             * @exception IOException		thrown on error
174:             */
175:            public void writeExternal(ObjectOutput out) throws IOException {
176:                FormatableHashtable fh = new FormatableHashtable();
177:                fh.put("name", name);
178:                fh.put("dataType", dataType);
179:                fh.put("defaultValue", defaultValue);
180:                fh.put("defaultInfo", defaultInfo);
181:                fh.put("newDefaultUUID", newDefaultUUID);
182:                fh.put("oldDefaultUUID", oldDefaultUUID);
183:                fh.putInt("action", action);
184:
185:                if (autoincInc != 0) {
186:                    // only write out autoinc values if its an autoinc column.
187:                    fh.putLong("autoincStart", autoincStart);
188:                    fh.putLong("autoincInc", autoincInc);
189:                }
190:                out.writeObject(fh);
191:            }
192:
193:            /**
194:             * Get the formatID which corresponds to this class.
195:             *
196:             *	@return	the formatID of this class
197:             */
198:            public int getTypeFormatId() {
199:                return StoredFormatIds.COLUMN_INFO_V02_ID;
200:            }
201:
202:            /*
203:              Object methods.
204:             */
205:            public String toString() {
206:                if (SanityManager.DEBUG) {
207:                    String traceName;
208:                    String traceDataType;
209:                    String traceDefaultValue;
210:                    String traceDefaultInfo;
211:                    String traceNewDefaultUUID;
212:                    String traceOldDefaultUUID;
213:                    String traceAction;
214:                    String traceAI;
215:                    if (name == null) {
216:                        traceName = "name: null ";
217:                    } else {
218:                        traceName = "name: " + name + " ";
219:                    }
220:
221:                    if (dataType == null) {
222:                        traceDataType = "dataType: null ";
223:                    } else {
224:                        traceDataType = "dataType: " + dataType + " ";
225:                    }
226:
227:                    if (defaultValue == null) {
228:                        traceDefaultValue = "defaultValue: null ";
229:                    } else {
230:                        traceDefaultValue = "defaultValue: " + defaultValue
231:                                + " ";
232:                    }
233:
234:                    if (defaultInfo == null) {
235:                        traceDefaultInfo = "defaultInfo: null ";
236:                    } else {
237:                        traceDefaultInfo = "defaultInfo: " + defaultInfo + " ";
238:                    }
239:
240:                    if (newDefaultUUID == null) {
241:                        traceNewDefaultUUID = "newDefaultUUID: null ";
242:                    } else {
243:                        traceNewDefaultUUID = "newDefaultUUID: "
244:                                + newDefaultUUID + " ";
245:                    }
246:
247:                    if (oldDefaultUUID == null) {
248:                        traceOldDefaultUUID = "oldDefaultUUID: null ";
249:                    } else {
250:                        traceOldDefaultUUID = "oldDefaultUUID: "
251:                                + oldDefaultUUID + " ";
252:                    }
253:
254:                    traceAction = "action: " + action + " ";
255:
256:                    if (autoincInc != 0) {
257:                        traceAI = "autoincrement, start: " + autoincStart
258:                                + " increment:" + autoincInc;
259:                    } else {
260:                        traceAI = "NOT autoincrement";
261:                    }
262:                    return "ColumnInfo: (" + traceName + traceDataType
263:                            + traceDefaultValue + traceDefaultInfo
264:                            + traceNewDefaultUUID + traceOldDefaultUUID
265:                            + traceAction + traceAI + ")";
266:                } else {
267:                    return "";
268:                }
269:            }
270:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.