1 | /* |
2 | |
3 | Derby - Class org.apache.derby.iapi.sql.dictionary.SubConstraintDescriptor |
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 SubConstraintDescriptor. |
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 abstract class SubConstraintDescriptor extends TupleDescriptor |
38 | implements UniqueTupleDescriptor |
39 | { |
40 | |
41 | /** |
42 | public interface for this class: |
43 | <ol> |
44 | <li> public void setConstraintId(UUID constraintId);</li> |
45 | <li>public boolean hasBackingIndex();</li> |
46 | <li>public void setTableDescriptor(TableDescriptor td);</li> |
47 | <li>public TableDescriptor getTableDescriptor();</li> |
48 | </ol> |
49 | */ |
50 | |
51 | // Implementation |
52 | TableDescriptor td; |
53 | UUID constraintId; |
54 | |
55 | /** |
56 | * Constructor for a SubConstraintDescriptorImpl |
57 | * |
58 | * @param constraintId The UUID of the constraint. |
59 | */ |
60 | |
61 | SubConstraintDescriptor(UUID constraintId) |
62 | { |
63 | this.constraintId = constraintId; |
64 | } |
65 | |
66 | /** |
67 | * Sets the UUID of the constraint. |
68 | * |
69 | * @param constraintId The constraint Id. |
70 | */ |
71 | public void setConstraintId(UUID constraintId) |
72 | { |
73 | this.constraintId = constraintId; |
74 | } |
75 | |
76 | /** |
77 | * Gets the UUID of the constraint. |
78 | * |
79 | * @return The UUID of the constraint. |
80 | */ |
81 | public UUID getUUID() |
82 | { |
83 | return constraintId; |
84 | } |
85 | |
86 | /** |
87 | * Does this constraint have a backing index? |
88 | * |
89 | * @return boolean Whether or not there is a backing index for this constraint. |
90 | */ |
91 | public abstract boolean hasBackingIndex(); |
92 | |
93 | /** |
94 | * Caches the TableDescriptor of the |
95 | * table that the constraint is on. |
96 | * |
97 | * @param td The TableDescriptor. |
98 | */ |
99 | public void setTableDescriptor(TableDescriptor td) |
100 | { |
101 | this.td = td; |
102 | } |
103 | |
104 | /** |
105 | * Returns the cached TableDescriptor, if |
106 | * supplied, that the constraint is on. |
107 | * |
108 | * @return The cached TableDescriptor, |
109 | * if supplied. |
110 | */ |
111 | public TableDescriptor getTableDescriptor() |
112 | { |
113 | return td; |
114 | } |
115 | |
116 | /** |
117 | * Convert the SubConstraintDescriptor to a String. |
118 | * |
119 | * @return A String representation of this SubConstraintDescriptor |
120 | */ |
121 | |
122 | public String toString() |
123 | { |
124 | if (SanityManager.DEBUG) |
125 | { |
126 | return "constraintId: " + constraintId + "\n"; |
127 | } |
128 | else |
129 | { |
130 | return ""; |
131 | } |
132 | } |
133 | |
134 | } |