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


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.sql.GenericColumnDescriptor
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;
023:
024:        import org.apache.derby.iapi.sql.ResultColumnDescriptor;
025:        import org.apache.derby.iapi.types.DataTypeDescriptor;
026:
027:        import org.apache.derby.iapi.services.sanity.SanityManager;
028:
029:        import org.apache.derby.iapi.services.io.StoredFormatIds;
030:        import org.apache.derby.iapi.services.io.FormatIdUtil;
031:        import org.apache.derby.iapi.services.io.Formatable;
032:
033:        import org.apache.derby.iapi.services.io.FormatableHashtable;
034:        import org.apache.derby.iapi.services.io.FormatableIntHolder;
035:
036:        import java.io.ObjectOutput;
037:        import java.io.ObjectInput;
038:        import java.io.IOException;
039:
040:        /**
041:         * This is a stripped down implementation of a column
042:         * descriptor that is intended for generic use.  It
043:         * can be seralized and attached to plans.
044:         *
045:         * @author jamie
046:         */
047:        public final class GenericColumnDescriptor implements 
048:                ResultColumnDescriptor, Formatable {
049:
050:            /********************************************************
051:             **
052:             **	This class implements Formatable. That means that it
053:             **	can write itself to and from a formatted stream. If
054:             **	you add more fields to this class, make sure that you
055:             **	also write/read them with the writeExternal()/readExternal()
056:             **	methods.
057:             **
058:             **	If, inbetween releases, you add more fields to this class,
059:             **	then you should bump the version number emitted by the getTypeFormatId()
060:             **	method.
061:             **
062:             ********************************************************/
063:
064:            private String name;
065:            private String schemaName;
066:            private String tableName;
067:            private int columnPos;
068:            private DataTypeDescriptor type;
069:            private boolean isAutoincrement;
070:            private boolean updatableByCursor;
071:
072:            /**
073:             * Niladic constructor for Formatable
074:             */
075:            public GenericColumnDescriptor() {
076:            }
077:
078:            public GenericColumnDescriptor(String name, DataTypeDescriptor type) {
079:                this .name = name;
080:                this .type = type;
081:            }
082:
083:            /** 
084:             * This constructor is used to build a generic (and
085:             * formatable) ColumnDescriptor.  The idea is that
086:             * it can be passed a ColumnDescriptor from a query
087:             * tree and convert it to something that can be used
088:             * anywhere.
089:             *
090:             * @param rcd the ResultColumnDescriptor
091:             */
092:            public GenericColumnDescriptor(ResultColumnDescriptor rcd) {
093:                name = rcd.getName();
094:                tableName = rcd.getSourceTableName();
095:                schemaName = rcd.getSourceSchemaName();
096:                columnPos = rcd.getColumnPosition();
097:                type = rcd.getType();
098:                isAutoincrement = rcd.isAutoincrement();
099:                updatableByCursor = rcd.updatableByCursor();
100:            }
101:
102:            /**
103:             * Returns a DataTypeDescriptor for the column. This DataTypeDescriptor
104:             * will not represent an actual value, it will only represent the type
105:             * that all values in the column will have.
106:             *
107:             * @return	A DataTypeDescriptor describing the type of the column.
108:             */
109:            public DataTypeDescriptor getType() {
110:                return type;
111:            }
112:
113:            /**
114:             * Returns the name of the Column.
115:             *
116:             * @return	A String containing the name of the column.
117:             */
118:            public String getName() {
119:                return name;
120:            }
121:
122:            /**
123:             * Get the name of the schema for the Column's base table, if any.
124:             * Following example queries will all return APP (assuming user is in schema APP)
125:             * select t.a from t
126:             * select b.a from t as b
127:             * select app.t.a from t
128:             *
129:             * @return	A String containing the name of the schema of the Column's table.
130:             *		If the column is not in a schema (i.e. is a derived column), it returns NULL.
131:             */
132:            public String getSourceSchemaName() {
133:                return schemaName;
134:            }
135:
136:            /**
137:             * Get the name of the underlying(base) table this column comes from, if any.
138:             * Following example queries will all return T
139:             * select a from t
140:             * select b.a from t as b
141:             * select t.a from t
142:             *
143:             * @return	A String containing the name of the Column's base table.
144:             *		If the column is not in a table (i.e. is a derived column), it returns NULL.
145:             */
146:            public String getSourceTableName() {
147:                return tableName;
148:            }
149:
150:            /**
151:             * Get the position of the Column.
152:             * NOTE - position is 1-based.
153:             *
154:             * @return	An int containing the position of the Column
155:             *		within the table.
156:             */
157:            public int getColumnPosition() {
158:                return columnPos;
159:            }
160:
161:            public boolean isAutoincrement() {
162:                return isAutoincrement;
163:            }
164:
165:            public boolean updatableByCursor() {
166:                return updatableByCursor;
167:            }
168:
169:            //////////////////////////////////////////////
170:            //
171:            // FORMATABLE
172:            //
173:            //////////////////////////////////////////////
174:            /**
175:             * Write this object out
176:             *
177:             * @param out write bytes here
178:             *
179:             * @exception IOException thrown on error
180:             */
181:            public void writeExternal(ObjectOutput out) throws IOException {
182:                FormatableHashtable fh = new FormatableHashtable();
183:                fh.put("name", name);
184:                fh.put("tableName", tableName);
185:                fh.put("schemaName", schemaName);
186:                fh.putInt("columnPos", columnPos);
187:                fh.put("type", type);
188:                fh.putBoolean("isAutoincrement", isAutoincrement);
189:                fh.putBoolean("updatableByCursor", updatableByCursor);
190:                out.writeObject(fh);
191:                return;
192:            }
193:
194:            public void djdrcd() {
195:            }
196:
197:            /**
198:             * Read this object from a stream of stored objects.
199:             *
200:             * @param in read this.
201:             *
202:             * @exception IOException					thrown on error
203:             * @exception ClassNotFoundException		thrown on error
204:             */
205:            public void readExternal(ObjectInput in) throws IOException,
206:                    ClassNotFoundException {
207:                FormatableHashtable fh = (FormatableHashtable) in.readObject();
208:                name = (String) fh.get("name");
209:                tableName = (String) fh.get("tableName");
210:                schemaName = (String) fh.get("schemaName");
211:                columnPos = fh.getInt("columnPos");
212:                type = (DataTypeDescriptor) fh.get("type");
213:                isAutoincrement = fh.getBoolean("isAutoincrement");
214:                updatableByCursor = fh.getBoolean("updatableByCursor");
215:            }
216:
217:            /**
218:             * Get the formatID which corresponds to this class.
219:             *
220:             *	@return	the formatID of this class
221:             */
222:            public int getTypeFormatId() {
223:                return StoredFormatIds.GENERIC_COLUMN_DESCRIPTOR_V02_ID;
224:            }
225:
226:            public String toString() {
227:                if (SanityManager.DEBUG) {
228:                    return "GenericColumnDescriptor\n\tname: " + name
229:                            + "\n\tTable: " + schemaName + "." + tableName
230:                            + "\n\tcolumnPos: " + columnPos + "\n\tType: "
231:                            + type;
232:                } else {
233:                    return "";
234:                }
235:            }
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.