1 21 22 package org.apache.derby.iapi.sql.dictionary; 23 import org.apache.derby.catalog.ReferencedColumns; 24 import org.apache.derby.catalog.UUID; 25 import org.apache.derby.iapi.services.sanity.SanityManager; 26 import org.apache.derby.iapi.sql.StatementType; 27 28 33 public class CheckConstraintDescriptor extends ConstraintDescriptor 34 { 35 ReferencedColumns referencedColumns; 36 String constraintText; 37 38 CheckConstraintDescriptor( 39 DataDictionary dataDictionary, 40 TableDescriptor table, 41 String constraintName, 42 boolean deferrable, 43 boolean initiallyDeferred, 44 UUID constraintId, 45 String constraintText, 46 ReferencedColumns referencedColumns, 47 SchemaDescriptor schemaDesc, 48 boolean isEnabled 49 ) 50 { 51 super(dataDictionary, table, constraintName, deferrable, 52 initiallyDeferred, (int []) null, 53 constraintId, schemaDesc, isEnabled); 54 this.constraintText = constraintText; 55 this.referencedColumns = referencedColumns; 56 } 57 58 63 public boolean hasBackingIndex() 64 { 65 return false; 66 } 67 68 75 public int getConstraintType() 76 { 77 return DataDictionary.CHECK_CONSTRAINT; 78 } 79 80 85 public String getConstraintText() 86 { 87 return constraintText; 88 } 89 90 95 public UUID getConglomerateId() 96 { 97 return null; 98 } 99 100 105 public ReferencedColumns getReferencedColumnsDescriptor() 106 { 107 return referencedColumns; 108 } 109 110 115 public void setReferencedColumnsDescriptor(ReferencedColumns rcd) 116 { 117 referencedColumns = rcd; 118 } 119 120 125 public int[] getReferencedColumns() 126 { 127 return referencedColumns.getReferencedColumnPositions(); 128 } 129 130 141 public boolean needsToFire(int stmtType, int[] modifiedCols) 142 { 143 146 if (!isEnabled) 147 { 148 return false; 149 } 150 151 if (stmtType == StatementType.INSERT) 152 { 153 return true; 154 } 155 156 if (stmtType == StatementType.DELETE) 157 { 158 return false; 159 } 160 161 return doColumnsIntersect(modifiedCols, getReferencedColumns()); 163 } 164 165 170 171 public String toString() 172 { 173 if (SanityManager.DEBUG) 174 { 175 return "constraintText: " + constraintText + "\n" + 176 "referencedColumns: " + referencedColumns + "\n" + 177 super.toString(); 178 } 179 else 180 { 181 return ""; 182 } 183 } 184 185 186 } 187 | Popular Tags |