001: /*
002:
003: Derby - Class org.apache.derby.iapi.sql.dictionary.SubKeyConstraintDescriptor
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.iapi.sql.dictionary;
023:
024: import org.apache.derby.catalog.UUID;
025: import org.apache.derby.iapi.services.sanity.SanityManager;
026:
027: /**
028: * This interface is used to get information from a SubKeyConstraintDescriptor.
029: * A SubKeyConstraintDescriptor is used within the DataDictionary to
030: * get auxiliary constraint information from the system table
031: * that is auxiliary to sysconstraints.
032: *
033: * @version 0.1
034: * @author Jerry Brenner
035: */
036:
037: public class SubKeyConstraintDescriptor extends SubConstraintDescriptor {
038: /** Interface for SubKeyConstraintDescriptor is
039: <ol>
040: <li>public UUID getIndexId();</li>
041: <li>public UUID getKeyConstraintId();</li>
042: </ol>
043: */
044:
045: // Implementation
046: UUID indexId;
047: UUID keyConstraintId;
048:
049: int raDeleteRule; //referential action rule for a DELETE
050: int raUpdateRule; //referential action rule for a UPDATE
051:
052: /**
053: * Constructor for a SubConstraintDescriptorImpl
054: *
055: * @param constraintId The UUID of the constraint.
056: * @param indexId The UUID of the backing index.
057: */
058: public SubKeyConstraintDescriptor(UUID constraintId, UUID indexId) {
059: super (constraintId);
060: this .indexId = indexId;
061: }
062:
063: /**
064: * Constructor for a SubConstraintDescriptor
065: *
066: * @param constraintId The UUID of the constraint.
067: * @param indexId The UUID of the backing index.
068: * @param keyConstraintId The UUID of the referenced constraint (fks)
069: */
070: public SubKeyConstraintDescriptor(UUID constraintId, UUID indexId,
071: UUID keyConstraintId) {
072: this (constraintId, indexId);
073: this .keyConstraintId = keyConstraintId;
074: }
075:
076: /**
077: * Constructor for a SubConstraintDescriptor
078: *
079: * @param constraintId The UUID of the constraint.
080: * @param indexId The UUID of the backing index.
081: * @param keyConstraintId The UUID of the referenced constraint (fks)
082: * @param raDeleteRule The referential action for delete
083: * @param raUpdateRule The referential action for update
084: */
085: public SubKeyConstraintDescriptor(UUID constraintId, UUID indexId,
086: UUID keyConstraintId, int raDeleteRule, int raUpdateRule) {
087: this (constraintId, indexId);
088: this .keyConstraintId = keyConstraintId;
089: this .raDeleteRule = raDeleteRule;
090: this .raUpdateRule = raUpdateRule;
091: }
092:
093: /**
094: * Gets the UUID of the backing index.
095: *
096: * @return The UUID of the backing index.
097: */
098: public UUID getIndexId() {
099: return indexId;
100: }
101:
102: /**
103: * Gets the UUID of the referenced key constraint
104: *
105: * @return The UUID of the referenced key constraint
106: */
107: public UUID getKeyConstraintId() {
108: return keyConstraintId;
109: }
110:
111: /**
112: * Does this constraint have a backing index?
113: *
114: * @return boolean Whether or not there is a backing index for this constraint.
115: */
116: public boolean hasBackingIndex() {
117: return true;
118: }
119:
120: /**
121: * Gets a referential action rule on a DELETE
122: * @return referential rule defined by the user during foreign key creattion
123: * for a delete (like CASCDE , RESTRICT ..etc)
124: */
125: public int getRaDeleteRule() {
126: return raDeleteRule;
127: }
128:
129: /**
130: * Gets a referential action rule on a UPDATE
131: * @return referential rule defined by the user during foreign key creattion
132: * for an UPDATE (like CASCDE , RESTRICT ..etc)
133: */
134: public int getRaUpdateRule() {
135: return raUpdateRule;
136: }
137:
138: /**
139: * Convert the SubKeyConstraintDescriptor to a String.
140: *
141: * @return A String representation of this SubConstraintDescriptor
142: */
143:
144: public String toString() {
145: if (SanityManager.DEBUG) {
146: return "indexId: " + indexId + "\n" + "keyConstraintId: "
147: + keyConstraintId + "\n" + "raDeleteRule: "
148: + raDeleteRule + "\n" + "raUpdateRule: "
149: + raUpdateRule + "\n" + super .toString();
150: } else {
151: return "";
152: }
153: }
154:
155: }
|