KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > execute > DeleteConstantAction


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.DeleteConstantAction
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql.execute;
23
24 import org.apache.derby.iapi.services.io.ArrayUtil;
25 import org.apache.derby.iapi.services.io.StoredFormatIds;
26 import org.apache.derby.iapi.services.io.FormatIdUtil;
27
28 import org.apache.derby.iapi.sql.dictionary.IndexRowGenerator;
29
30 import org.apache.derby.iapi.sql.execute.ConstantAction;
31 import org.apache.derby.iapi.sql.execute.ExecRow;
32
33 import org.apache.derby.iapi.error.StandardException;
34
35 import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo;
36
37 import org.apache.derby.catalog.UUID;
38
39 import org.apache.derby.iapi.services.io.FormatableBitSet;
40 import org.apache.derby.iapi.sql.ResultDescription;
41
42 import java.io.ObjectOutput JavaDoc;
43 import java.io.ObjectInput JavaDoc;
44 import java.io.IOException JavaDoc;
45
46 import java.util.Properties JavaDoc;
47
48
49 /**
50  * This class describes compiled constants that are passed into
51  * DeleteResultSets.
52  *
53  * @author Rick Hillegas
54  */

55
56 public class DeleteConstantAction extends WriteCursorConstantAction
57 {
58     /********************************************************
59     **
60     ** This class implements Formatable. But it is NOT used
61     ** across either major or minor releases. It is only
62     ** written persistently in stored prepared statements,
63     ** not in the replication stage. SO, IT IS OK TO CHANGE
64     ** ITS read/writeExternal.
65     **
66     ********************************************************/

67     
68     int numColumns;
69     ConstantAction[] dependentCActions; //constant action for the dependent table
70
ResultDescription resultDescription; //required for dependent tables.
71

72     // CONSTRUCTORS
73

74     /**
75      * Public niladic constructor. Needed for Formatable interface to work.
76      *
77      */

78     public DeleteConstantAction() { super(); }
79
80     /**
81      * Make the ConstantAction for an DELETE statement.
82      *
83      * @param conglomId Conglomerate ID.
84      * @param heapSCOCI StaticCompiledOpenConglomInfo for heap.
85      * @param irgs Index descriptors
86      * @param indexCIDS Conglomerate IDs of indices
87      * @param indexSCOCIs StaticCompiledOpenConglomInfos for indexes.
88      * @param emptyHeapRow Template for heap row.
89      * @param deferred True means process as a deferred insert.
90      * @param targetUUID UUID of target table
91      * @param lockMode The lock mode to use
92      * (row or table, see TransactionController)
93      * @param fkInfo Array of structures containing foreign key info, if any (may be null)
94      * @param triggerInfo Array of structures containing trigger info, if any (may be null)
95      * @param baseRowReadList Map of columns read in. 1 based.
96      * @param streamStorableHeapColIds Null for non rep. (0 based)
97      * @param numColumns Number of columns to read.
98      * @param singleRowSource Whether or not source is a single row source
99      */

100     public DeleteConstantAction(
101                                 long conglomId,
102                                 StaticCompiledOpenConglomInfo heapSCOCI,
103                                 IndexRowGenerator[] irgs,
104                                 long[] indexCIDS,
105                                 StaticCompiledOpenConglomInfo[] indexSCOCIs,
106                                 ExecRow emptyHeapRow,
107                                 boolean deferred,
108                                 UUID targetUUID,
109                                 int lockMode,
110                                 FKInfo[] fkInfo,
111                                 TriggerInfo triggerInfo,
112                                 FormatableBitSet baseRowReadList,
113                                 int[] baseRowReadMap,
114                                 int[] streamStorableHeapColIds,
115                                 int numColumns,
116                                 boolean singleRowSource,
117                                 ResultDescription resultDescription,
118                                 ConstantAction[] dependentCActions)
119     {
120         super( conglomId,
121                heapSCOCI,
122                irgs, indexCIDS, indexSCOCIs,
123                null, // index names not needed for delete.
124
deferred,
125                (Properties JavaDoc) null,
126                targetUUID,
127                lockMode,
128                fkInfo,
129                triggerInfo,
130                emptyHeapRow,
131                baseRowReadList,
132                baseRowReadMap,
133                streamStorableHeapColIds,
134                singleRowSource
135                );
136
137         this.numColumns = numColumns;
138         this.resultDescription = resultDescription;
139         this.dependentCActions = dependentCActions;
140     }
141
142     // INTERFACE METHODS
143

144     // Formatable methods
145

146     /**
147       @see java.io.Externalizable#readExternal
148       @exception IOException thrown on error
149       @exception ClassNotFoundException thrown on error
150       */

151     public void readExternal( ObjectInput JavaDoc in )
152          throws IOException JavaDoc, ClassNotFoundException JavaDoc
153     {
154         super.readExternal(in);
155         numColumns = in.readInt();
156
157         //information required for cascade delete
158
dependentCActions = new ConstantAction[ArrayUtil.readArrayLength(in)];
159         ArrayUtil.readArrayItems(in, dependentCActions);
160         resultDescription = (ResultDescription) in.readObject();
161
162     }
163
164     /**
165
166       @exception IOException thrown on error
167       */

168     public void writeExternal( ObjectOutput JavaDoc out )
169          throws IOException JavaDoc
170     {
171         super.writeExternal(out);
172         out.writeInt(numColumns);
173
174         //write cascade delete information
175
ArrayUtil.writeArray(out, dependentCActions);
176         out.writeObject(resultDescription);
177
178     }
179
180     /**
181      * Get the formatID which corresponds to this class.
182      *
183      * @return the formatID of this class
184      */

185     public int getTypeFormatId() { return StoredFormatIds.DELETE_CONSTANT_ACTION_V01_ID; }
186
187     // KeyToBaseRowConstantAction METHODS
188
}
189
Popular Tags