KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > catalog > DDColumnDependableFinder


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.catalog.DDColumnDependableFinder
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.catalog;
23
24 import org.apache.derby.catalog.UUID;
25 import org.apache.derby.catalog.Dependable;
26 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
27 import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
28 import org.apache.derby.iapi.error.StandardException;
29
30 import org.apache.derby.iapi.services.io.FormatableHashtable;
31 import org.apache.derby.iapi.services.io.FormatableBitSet;
32
33 import java.io.ObjectOutput JavaDoc;
34 import java.io.ObjectInput JavaDoc;
35 import java.io.IOException JavaDoc;
36
37 /**
38  * Class for implementation of DependableFinder in the core DataDictionary
39  * for referenced columns in a table.
40  *
41  *
42  * @author Tingjian Ge
43  */

44
45 public class DDColumnDependableFinder extends DDdependableFinder
46 {
47     ////////////////////////////////////////////////////////////////////////
48
//
49
// STATE
50
//
51
////////////////////////////////////////////////////////////////////////
52

53     // write least amount of data to disk, just the byte array, not even
54
// a FormatableBitSet
55
private byte[] columnBitMap;
56
57     ////////////////////////////////////////////////////////////////////////
58
//
59
// CONSTRUCTORS
60
//
61
////////////////////////////////////////////////////////////////////////
62

63     /**
64      * Constructor same as in parent.
65      */

66     public DDColumnDependableFinder(int formatId)
67     {
68         super(formatId);
69     }
70
71     /**
72      * Constructor given referenced column bit map byte array as in FormatableBitSet
73      */

74     public DDColumnDependableFinder(int formatId, byte[] columnBitMap)
75     {
76         super(formatId);
77         this.columnBitMap = columnBitMap;
78     }
79
80     ////////////////////////////////////////////////////////////////////////
81
//
82
// DDColumnDependable METHODS
83
//
84
////////////////////////////////////////////////////////////////////////
85

86     /**
87      * Get the byte array encoding the bitmap of referenced columns in
88      * a table.
89      *
90      * @return byte array as in a FormatableBitSet encoding column bit map
91      */

92     public byte[] getColumnBitMap()
93     {
94         return columnBitMap;
95     }
96
97     /**
98      * Set the byte array encoding the bitmap of referenced columns in
99      * a table.
100      *
101      * @param columnBitMap byte array as in a FormatableBitSet encoding column bit map
102      */

103     public void setColumnBitMap(byte[] columnBitMap)
104     {
105         this.columnBitMap = columnBitMap;
106     }
107
108     /**
109      * Get a dependable object, which is essentially a table descriptor with
110      * referencedColumnMap field set.
111      *
112      * @param dd data dictionary
113      * @param dependableObjectID dependable object ID (table UUID)
114      * @return a dependable, a table descriptor with referencedColumnMap
115      * field set
116      */

117     protected Dependable getDependable(DataDictionary dd, UUID dependableObjectID)
118         throws StandardException
119     {
120         TableDescriptor td = dd.getTableDescriptor(dependableObjectID);
121         if (td != null) // see beetle 4444
122
td.setReferencedColumnMap(new FormatableBitSet(columnBitMap));
123         return td;
124     }
125
126     //////////////////////////////////////////////////////////////////
127
//
128
// FORMATABLE METHODS
129
//
130
//////////////////////////////////////////////////////////////////
131

132     /**
133      * Read this object from a stream of stored objects. Just read the
134      * byte array, besides what the parent does.
135      *
136      * @param in read this.
137      */

138     public void readExternal( ObjectInput JavaDoc in )
139             throws IOException JavaDoc, ClassNotFoundException JavaDoc
140     {
141         super.readExternal(in);
142         FormatableHashtable fh = (FormatableHashtable)in.readObject();
143         columnBitMap = (byte[])fh.get("columnBitMap");
144     }
145
146     /**
147      * Write this object to a stream of stored objects. Just write the
148      * byte array, besides what the parent does.
149      *
150      * @param out write bytes here.
151      */

152     public void writeExternal( ObjectOutput JavaDoc out )
153             throws IOException JavaDoc
154     {
155         super.writeExternal(out);
156         FormatableHashtable fh = new FormatableHashtable();
157         fh.put("columnBitMap", columnBitMap);
158         out.writeObject(fh);
159     }
160 }
161
Popular Tags