1 | /* |
2 | |
3 | Derby - Class org.apache.derby.iapi.sql.dictionary.SubKeyConstraintDescriptor |
4 | |
5 | Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.iapi.sql.dictionary; |
22 | |
23 | |
24 | import org.apache.derby.catalog.UUID; |
25 | import org.apache.derby.iapi.services.sanity.SanityManager; |
26 | |
27 | /** |
28 | * This interface is used to get information from a SubKeyConstraintDescriptor. |
29 | * A SubKeyConstraintDescriptor is used within the DataDictionary to |
30 | * get auxiliary constraint information from the system table |
31 | * that is auxiliary to sysconstraints. |
32 | * |
33 | * @version 0.1 |
34 | * @author Jerry Brenner |
35 | */ |
36 | |
37 | public class SubKeyConstraintDescriptor extends SubConstraintDescriptor |
38 | { |
39 | /** Interface for SubKeyConstraintDescriptor is |
40 | <ol> |
41 | <li>public UUID getIndexId();</li> |
42 | <li>public UUID getKeyConstraintId();</li> |
43 | </ol> |
44 | */ |
45 | |
46 | // Implementation |
47 | UUID indexId; |
48 | UUID keyConstraintId; |
49 | |
50 | int raDeleteRule; //referential action rule for a DELETE |
51 | int raUpdateRule; //referential action rule for a UPDATE |
52 | |
53 | |
54 | /** |
55 | * Constructor for a SubConstraintDescriptorImpl |
56 | * |
57 | * @param constraintId The UUID of the constraint. |
58 | * @param indexId The UUID of the backing index. |
59 | */ |
60 | public SubKeyConstraintDescriptor(UUID constraintId, UUID indexId) |
61 | { |
62 | super(constraintId); |
63 | this.indexId = indexId; |
64 | } |
65 | |
66 | /** |
67 | * Constructor for a SubConstraintDescriptor |
68 | * |
69 | * @param constraintId The UUID of the constraint. |
70 | * @param indexId The UUID of the backing index. |
71 | * @param keyConstraintId The UUID of the referenced constraint (fks) |
72 | */ |
73 | public SubKeyConstraintDescriptor(UUID constraintId, UUID indexId, UUID keyConstraintId) |
74 | { |
75 | this(constraintId, indexId); |
76 | this.keyConstraintId = keyConstraintId; |
77 | } |
78 | |
79 | |
80 | /** |
81 | * Constructor for a SubConstraintDescriptor |
82 | * |
83 | * @param constraintId The UUID of the constraint. |
84 | * @param indexId The UUID of the backing index. |
85 | * @param keyConstraintId The UUID of the referenced constraint (fks) |
86 | * @param raDeleteRule The referential action for delete |
87 | * @param raUpdateRule The referential action for update |
88 | */ |
89 | public SubKeyConstraintDescriptor(UUID constraintId, UUID indexId, UUID |
90 | keyConstraintId, int raDeleteRule, int raUpdateRule) |
91 | { |
92 | this(constraintId, indexId); |
93 | this.keyConstraintId = keyConstraintId; |
94 | this.raDeleteRule = raDeleteRule; |
95 | this.raUpdateRule = raUpdateRule; |
96 | } |
97 | |
98 | |
99 | |
100 | |
101 | |
102 | /** |
103 | * Gets the UUID of the backing index. |
104 | * |
105 | * @return The UUID of the backing index. |
106 | */ |
107 | public UUID getIndexId() |
108 | { |
109 | return indexId; |
110 | } |
111 | |
112 | /** |
113 | * Gets the UUID of the referenced key constraint |
114 | * |
115 | * @return The UUID of the referenced key constraint |
116 | */ |
117 | public UUID getKeyConstraintId() |
118 | { |
119 | return keyConstraintId; |
120 | } |
121 | |
122 | /** |
123 | * Does this constraint have a backing index? |
124 | * |
125 | * @return boolean Whether or not there is a backing index for this constraint. |
126 | */ |
127 | public boolean hasBackingIndex() |
128 | { |
129 | return true; |
130 | } |
131 | |
132 | /** |
133 | * Gets a referential action rule on a DELETE |
134 | * @return referential rule defined by the user during foreign key creattion |
135 | * for a delete (like CASCDE , RESTRICT ..etc) |
136 | */ |
137 | public int getRaDeleteRule() |
138 | { |
139 | return raDeleteRule; |
140 | } |
141 | |
142 | |
143 | /** |
144 | * Gets a referential action rule on a UPDATE |
145 | * @return referential rule defined by the user during foreign key creattion |
146 | * for an UPDATE (like CASCDE , RESTRICT ..etc) |
147 | */ |
148 | public int getRaUpdateRule() |
149 | { |
150 | return raUpdateRule; |
151 | } |
152 | |
153 | |
154 | |
155 | /** |
156 | * Convert the SubKeyConstraintDescriptor to a String. |
157 | * |
158 | * @return A String representation of this SubConstraintDescriptor |
159 | */ |
160 | |
161 | public String toString() |
162 | { |
163 | if (SanityManager.DEBUG) |
164 | { |
165 | return "indexId: " + indexId + "\n" + |
166 | "keyConstraintId: " + keyConstraintId + "\n" + |
167 | "raDeleteRule: " + raDeleteRule + "\n" + |
168 | "raUpdateRule: " + raUpdateRule + "\n" + |
169 | super.toString(); |
170 | } |
171 | else |
172 | { |
173 | return ""; |
174 | } |
175 | } |
176 | |
177 | } |