--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.iapi.sql.dictionary.KeyConstraintDescriptor\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.iapi.sql.dictionary;\r
+\r
+import org.apache.derby.iapi.error.StandardException;\r
+\r
+import org.apache.derby.catalog.UUID;\r
+import org.apache.derby.iapi.services.sanity.SanityManager;\r
+/**\r
+ * This interface is used to get information from a KeyConstraintDescriptor.\r
+ * A KeyConstraintDescriptor can represent a primary/unique/foreign key\r
+ * constraint.\r
+ *\r
+ * @version 0.1\r
+ */\r
+\r
+public abstract class KeyConstraintDescriptor extends ConstraintDescriptor\r
+{\r
+ /** interface to this class:\r
+ <ol>\r
+ <li>public UUID getIndexId();</li>\r
+ <li>public ConglomerateDescriptor getIndexConglomerateDescriptor(DataDictionary dd)</li>\r
+ throws StandardException;</li>\r
+ <li>public String getIndexUUIDString();</li>\r
+ <li>public int[] getKeyColumns();</li>\r
+ </ol>\r
+ */\r
+\r
+ // implementation\r
+ UUID indexId;\r
+\r
+ private ConglomerateDescriptor indexConglom;\r
+\r
+ /**\r
+ * Constructor for a KeyConstraintDescriptor\r
+ *\r
+ * @param dataDictionary The data dictionary that this descriptor lives in\r
+ * @param table The descriptor of the table the constraint is on\r
+ * @param constraintName The name of the constraint.\r
+ * @param deferrable If the constraint can be deferred.\r
+ * @param initiallyDeferred If the constraint starts life deferred.\r
+ * @param referencedColumns columns that the constraint references\r
+ * @param constraintId UUID of constraint\r
+ * @param indexId The UUID for the backing index\r
+ * @param schemaDesc The SchemaDescriptor for the constraint\r
+ * @param isEnabled is this constraint enabled\r
+ */\r
+ KeyConstraintDescriptor(\r
+ DataDictionary dataDictionary,\r
+ TableDescriptor table,\r
+ String constraintName,\r
+ boolean deferrable,\r
+ boolean initiallyDeferred,\r
+ int[] referencedColumns,\r
+ UUID constraintId,\r
+ UUID indexId,\r
+ SchemaDescriptor schemaDesc,\r
+ boolean isEnabled\r
+ ) \r
+ {\r
+ super(dataDictionary, table, constraintName, deferrable,\r
+ initiallyDeferred, referencedColumns,\r
+ constraintId, schemaDesc, isEnabled);\r
+ this.indexId = indexId;\r
+ }\r
+\r
+ /**\r
+ * Gets the UUID of the backing index for the constraint.\r
+ *\r
+ * @return The UUID of the backing index for the constraint.\r
+ */\r
+ public UUID getIndexId()\r
+ {\r
+ return indexId;\r
+ }\r
+\r
+ /**\r
+ * Gets the index conglomerate descriptor\r
+ *\r
+ * @return the index conglomerate descriptor\r
+ * \r
+ * @exception StandardException on error\r
+ */\r
+ public ConglomerateDescriptor getIndexConglomerateDescriptor(DataDictionary dd)\r
+ throws StandardException\r
+ {\r
+ if (indexConglom == null)\r
+ {\r
+ indexConglom = getTableDescriptor().getConglomerateDescriptor(indexId); \r
+ }\r
+ return indexConglom;\r
+ } \r
+ \r
+ /**\r
+ * Gets the UUID String of the backing index for the constraint.\r
+ *\r
+ * @return The UUID String of the backing index for the constraint.\r
+ */\r
+ public String getIndexUUIDString()\r
+ {\r
+ return indexId.toString();\r
+ }\r
+\r
+ /**\r
+ * Does this constraint have a backing index?\r
+ *\r
+ * @return boolean Whether or not there is a backing index for this constraint.\r
+ */\r
+ public boolean hasBackingIndex()\r
+ {\r
+ return true;\r
+ }\r
+\r
+ /**\r
+ * Get the UUID of the backing index, if one exists.\r
+ *\r
+ * @return The UUID of the backing index, if one exists, else null.\r
+ */\r
+ public UUID getConglomerateId()\r
+ {\r
+ return indexId;\r
+ }\r
+\r
+ /**\r
+ * Convert the SubConstraintDescriptor to a String.\r
+ *\r
+ * @return A String representation of this SubConstraintDescriptor\r
+ */\r
+\r
+ public String toString()\r
+ {\r
+ if (SanityManager.DEBUG)\r
+ {\r
+ return "indexId: " + indexId + "\n" +\r
+ super.toString();\r
+ }\r
+ else\r
+ {\r
+ return "";\r
+ }\r
+ }\r
+\r
+}\r