Source Code Cross Referenced for InsertConstantAction.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.InsertConstantAction
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.stream.HeaderPrintWriter;
025:
026:        import org.apache.derby.iapi.services.io.ArrayUtil;
027:        import org.apache.derby.iapi.services.io.StoredFormatIds;
028:        import org.apache.derby.iapi.services.io.FormatIdUtil;
029:
030:        import org.apache.derby.iapi.services.context.ContextManager;
031:
032:        import org.apache.derby.iapi.sql.dictionary.IndexRowGenerator;
033:        import org.apache.derby.iapi.sql.dictionary.DataDictionary;
034:        import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
035:        import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
036:        import org.apache.derby.iapi.sql.execute.ConstantAction;
037:        import org.apache.derby.iapi.sql.execute.ExecRow;
038:
039:        import org.apache.derby.iapi.error.StandardException;
040:
041:        import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo;
042:        import org.apache.derby.iapi.types.RowLocation;
043:
044:        import org.apache.derby.catalog.UUID;
045:
046:        import java.io.ObjectOutput;
047:        import java.io.ObjectInput;
048:        import java.io.IOException;
049:
050:        import java.util.Properties;
051:
052:        /**
053:         *	This class  describes compiled constants that are passed into
054:         *	InsertResultSets.
055:         *
056:         *	@author Rick Hillegas
057:         */
058:
059:        public class InsertConstantAction extends WriteCursorConstantAction {
060:            /********************************************************
061:             **
062:             **	This class implements Formatable. But it is NOT used
063:             **	across either major or minor releases.  It is only
064:             ** 	written persistently in stored prepared statements, 
065:             **	not in the replication stage.  SO, IT IS OK TO CHANGE
066:             **	ITS read/writeExternal.
067:             **
068:             ********************************************************/
069:
070:            /* Which (0-based) columns are indexed */
071:            boolean[] indexedCols;
072:
073:            /* These variables are needed to support Autoincrement-- after an insert
074:             * we need to remember the last autoincrement value inserted into the 
075:             * table and the user could do a search based on schema,table,columnname
076:             */
077:            private String schemaName;
078:            private String tableName;
079:            private String columnNames[];
080:
081:            /**
082:             * An array of row location objects (0 based), one for each
083:             * column in the table. If the column is an 
084:             * autoincrement table then the array points to
085:             * the row location of the column in SYSCOLUMNS.
086:             * if not, then it contains null.
087:             */
088:            protected RowLocation[] autoincRowLocation;
089:            private long[] autoincIncrement;
090:
091:            // CONSTRUCTORS
092:
093:            /**
094:             * Public niladic constructor. Needed for Formatable interface to work.
095:             *
096:             */
097:            public InsertConstantAction() {
098:                super ();
099:            }
100:
101:            /**
102:             *	Make the ConstantAction for an INSERT statement.
103:             *
104:             *  @param conglomId	Conglomerate ID.
105:             *	@param heapSCOCI	StaticCompiledOpenConglomInfo for heap.
106:             *  @param irgs			Index descriptors
107:             *  @param indexCIDS	Conglomerate IDs of indices
108:             *	@param indexSCOCIs	StaticCompiledOpenConglomInfos for indexes.
109:             *  @param indexNames   Names of indices on this table for error reporting.
110:             *  @param deferred		True means process as a deferred insert.
111:             *  @param targetProperties	Properties on the target table.
112:             *	@param targetUUID	UUID of target table
113:             *	@param lockMode		The lockMode to use on the target table
114:             *	@param fkInfo		Array of structures containing foreign key info, 
115:             *						if any (may be null)
116:             *	@param triggerInfo	Array of structures containing trigger info, 
117:             *						if any (may be null)
118:             *  @param streamStorableHeapColIds Null for non rep. (0 based)
119:             *  @param indexedCols	boolean[] of which (0-based) columns are indexed.
120:             *  @param singleRowSource		Whether or not source is a single row source
121:             *  @param autoincRowLocation Array of rowlocations of autoincrement values
122:             * 							  in SYSCOLUMNS for each ai column.
123:             */
124:            public InsertConstantAction(TableDescriptor tableDescriptor,
125:                    long conglomId, StaticCompiledOpenConglomInfo heapSCOCI,
126:                    IndexRowGenerator[] irgs, long[] indexCIDS,
127:                    StaticCompiledOpenConglomInfo[] indexSCOCIs,
128:                    String[] indexNames, boolean deferred,
129:                    Properties targetProperties, UUID targetUUID, int lockMode,
130:                    FKInfo[] fkInfo, TriggerInfo triggerInfo,
131:                    int[] streamStorableHeapColIds, boolean[] indexedCols,
132:                    boolean singleRowSource, RowLocation[] autoincRowLocation) {
133:                super (conglomId, heapSCOCI, irgs, indexCIDS, indexSCOCIs,
134:                        indexNames, deferred, targetProperties, targetUUID,
135:                        lockMode, fkInfo, triggerInfo, (ExecRow) null, // never need to pass in a heap row
136:                        null, null, streamStorableHeapColIds, singleRowSource);
137:                this .indexedCols = indexedCols;
138:                this .autoincRowLocation = autoincRowLocation;
139:                this .schemaName = tableDescriptor.getSchemaName();
140:                this .tableName = tableDescriptor.getName();
141:                this .columnNames = tableDescriptor.getColumnNamesArray();
142:                this .autoincIncrement = tableDescriptor
143:                        .getAutoincIncrementArray();
144:                this .indexNames = indexNames;
145:            }
146:
147:            // INTERFACE METHODS
148:
149:            // Formatable methods
150:            public void readExternal(ObjectInput in) throws IOException,
151:                    ClassNotFoundException {
152:                Object[] objectArray = null;
153:                super .readExternal(in);
154:                indexedCols = ArrayUtil.readBooleanArray(in);
155:
156:                // RESOLVEAUTOINCREMENT: this is the new stuff-- probably version!!
157:                objectArray = ArrayUtil.readObjectArray(in);
158:
159:                if (objectArray != null) {
160:                    // is there a better way to do cast the whole array?
161:                    autoincRowLocation = new RowLocation[objectArray.length];
162:                    for (int i = 0; i < objectArray.length; i++)
163:                        autoincRowLocation[i] = (RowLocation) objectArray[i];
164:                }
165:
166:                schemaName = (String) in.readObject();
167:                tableName = (String) in.readObject();
168:                objectArray = ArrayUtil.readObjectArray(in);
169:                if (objectArray != null) {
170:                    // is there a better way to do cast the whole array?
171:                    columnNames = new String[objectArray.length];
172:                    for (int i = 0; i < objectArray.length; i++)
173:                        columnNames[i] = (String) objectArray[i];
174:                }
175:
176:                autoincIncrement = ArrayUtil.readLongArray(in);
177:            }
178:
179:            /**
180:             * Write this object to a stream of stored objects.
181:             *
182:             * @param out write bytes here.
183:             *
184:             * @exception IOException		thrown on error
185:             */
186:            public void writeExternal(ObjectOutput out) throws IOException {
187:                super .writeExternal(out);
188:                ArrayUtil.writeBooleanArray(out, indexedCols);
189:                ArrayUtil.writeArray(out, autoincRowLocation);
190:                out.writeObject(schemaName);
191:                out.writeObject(tableName);
192:                ArrayUtil.writeArray(out, columnNames);
193:                ArrayUtil.writeLongArray(out, autoincIncrement);
194:            }
195:
196:            /**
197:             *	Gets the name of the schema that the table is in
198:             *
199:             *	@return	schema name
200:             */
201:            public String getSchemaName() {
202:                return schemaName;
203:            }
204:
205:            /**
206:             *	Gets the name of the table being inserted into
207:             *
208:             *	@return	name of table being inserted into
209:             */
210:            public String getTableName() {
211:                return tableName;
212:            }
213:
214:            /**
215:             * gets the name of the desired column in the taget table.
216:             * 
217:             * @param 	i	the column number
218:             */
219:            public String getColumnName(int i) {
220:                return columnNames[i];
221:            }
222:
223:            /**
224:             * gets the increment value for a column.
225:             *
226:             * @param 	i 	the column number
227:             */
228:            public long getAutoincIncrement(int i) {
229:                return autoincIncrement[i];
230:            }
231:
232:            /**
233:             * Does the target table has autoincrement columns.
234:             *
235:             * @return 	True if the table has ai columns
236:             */
237:            public boolean hasAutoincrement() {
238:                return (autoincRowLocation != null);
239:            }
240:
241:            /**
242:             * gets the row location 
243:             */
244:            public RowLocation[] getAutoincRowLocation() {
245:                return autoincRowLocation;
246:            }
247:
248:            /**
249:             * Get the formatID which corresponds to this class.
250:             *
251:             *	@return	the formatID of this class
252:             */
253:            public int getTypeFormatId() {
254:                return StoredFormatIds.INSERT_CONSTANT_ACTION_V01_ID;
255:            }
256:
257:            // CLASS METHODS
258:
259:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.