KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > sql > dictionary > SubKeyConstraintDescriptor


1 /*
2
3    Derby - Class org.apache.derby.iapi.sql.dictionary.SubKeyConstraintDescriptor
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.iapi.sql.dictionary;
23
24
25 import org.apache.derby.catalog.UUID;
26 import org.apache.derby.iapi.services.sanity.SanityManager;
27
28 /**
29  * This interface is used to get information from a SubKeyConstraintDescriptor.
30  * A SubKeyConstraintDescriptor is used within the DataDictionary to
31  * get auxiliary constraint information from the system table
32  * that is auxiliary to sysconstraints.
33  *
34  * @version 0.1
35  * @author Jerry Brenner
36  */

37
38 public class SubKeyConstraintDescriptor extends SubConstraintDescriptor
39 {
40     /** Interface for SubKeyConstraintDescriptor is
41         <ol>
42         <li>public UUID getIndexId();</li>
43         <li>public UUID getKeyConstraintId();</li>
44         </ol>
45     */

46
47     // Implementation
48
UUID indexId;
49     UUID keyConstraintId;
50
51     int raDeleteRule; //referential action rule for a DELETE
52
int raUpdateRule; //referential action rule for a UPDATE
53

54
55     /**
56      * Constructor for a SubConstraintDescriptorImpl
57      *
58      * @param constraintId The UUID of the constraint.
59      * @param indexId The UUID of the backing index.
60      */

61     public SubKeyConstraintDescriptor(UUID constraintId, UUID indexId)
62     {
63         super(constraintId);
64         this.indexId = indexId;
65     }
66
67     /**
68      * Constructor for a SubConstraintDescriptor
69      *
70      * @param constraintId The UUID of the constraint.
71      * @param indexId The UUID of the backing index.
72      * @param keyConstraintId The UUID of the referenced constraint (fks)
73      */

74     public SubKeyConstraintDescriptor(UUID constraintId, UUID indexId, UUID keyConstraintId)
75     {
76         this(constraintId, indexId);
77         this.keyConstraintId = keyConstraintId;
78     }
79
80
81     /**
82      * Constructor for a SubConstraintDescriptor
83      *
84      * @param constraintId The UUID of the constraint.
85      * @param indexId The UUID of the backing index.
86      * @param keyConstraintId The UUID of the referenced constraint (fks)
87      * @param raDeleteRule The referential action for delete
88      * @param raUpdateRule The referential action for update
89      */

90     public SubKeyConstraintDescriptor(UUID constraintId, UUID indexId, UUID
91                                       keyConstraintId, int raDeleteRule, int raUpdateRule)
92     {
93         this(constraintId, indexId);
94         this.keyConstraintId = keyConstraintId;
95         this.raDeleteRule = raDeleteRule;
96         this.raUpdateRule = raUpdateRule;
97     }
98
99
100
101
102
103     /**
104      * Gets the UUID of the backing index.
105      *
106      * @return The UUID of the backing index.
107      */

108     public UUID getIndexId()
109     {
110         return indexId;
111     }
112
113     /**
114      * Gets the UUID of the referenced key constraint
115      *
116      * @return The UUID of the referenced key constraint
117      */

118     public UUID getKeyConstraintId()
119     {
120         return keyConstraintId;
121     }
122
123     /**
124      * Does this constraint have a backing index?
125      *
126      * @return boolean Whether or not there is a backing index for this constraint.
127      */

128     public boolean hasBackingIndex()
129     {
130         return true;
131     }
132
133     /**
134      * Gets a referential action rule on a DELETE
135      * @return referential rule defined by the user during foreign key creattion
136      * for a delete (like CASCDE , RESTRICT ..etc)
137      */

138     public int getRaDeleteRule()
139     {
140         return raDeleteRule;
141     }
142     
143     
144     /**
145      * Gets a referential action rule on a UPDATE
146      * @return referential rule defined by the user during foreign key creattion
147      * for an UPDATE (like CASCDE , RESTRICT ..etc)
148      */

149     public int getRaUpdateRule()
150     {
151         return raUpdateRule;
152     }
153     
154
155
156     /**
157      * Convert the SubKeyConstraintDescriptor to a String.
158      *
159      * @return A String representation of this SubConstraintDescriptor
160      */

161
162     public String JavaDoc toString()
163     {
164         if (SanityManager.DEBUG)
165         {
166             return "indexId: " + indexId + "\n" +
167                 "keyConstraintId: " + keyConstraintId + "\n" +
168                 "raDeleteRule: " + raDeleteRule + "\n" +
169                 "raUpdateRule: " + raUpdateRule + "\n" +
170                 super.toString();
171         }
172         else
173         {
174             return "";
175         }
176     }
177
178 }
179
Popular Tags