1 21 22 package org.apache.derby.impl.sql.execute; 23 24 import org.apache.derby.iapi.services.sanity.SanityManager; 25 import org.apache.derby.iapi.error.StandardException; 26 27 import org.apache.derby.iapi.sql.execute.ExecRow; 28 import org.apache.derby.iapi.sql.execute.ExecIndexRow; 29 import org.apache.derby.iapi.store.access.TransactionController; 30 31 36 public class RISetChecker 37 { 38 private GenericRIChecker[] checkers; 39 40 46 public RISetChecker(TransactionController tc, FKInfo fkInfo[]) 47 throws StandardException 48 { 49 if (fkInfo == null) 50 { 51 return; 52 } 53 54 checkers = new GenericRIChecker[fkInfo.length]; 55 56 for (int i = 0; i < fkInfo.length; i++) 57 { 58 checkers[i] = (fkInfo[i].type == FKInfo.FOREIGN_KEY) ? 59 (GenericRIChecker)new ForeignKeyRIChecker(tc, fkInfo[i]) : 60 (GenericRIChecker)new ReferencedKeyRIChecker(tc, fkInfo[i]); 61 } 62 } 63 64 71 void reopen() throws StandardException 72 { 73 } 75 76 88 public void doPKCheck(ExecRow row, boolean restrictCheckOnly) throws StandardException 89 { 90 if (checkers == null) 91 return; 92 93 for (int i = 0; i < checkers.length; i++) 94 { 95 if (checkers[i] instanceof ReferencedKeyRIChecker) 96 { 97 checkers[i].doCheck(row,restrictCheckOnly); 98 } 99 } 100 } 101 102 112 public void doFKCheck(ExecRow row) throws StandardException 113 { 114 if (checkers == null) 115 return; 116 117 for (int i = 0; i < checkers.length; i++) 118 { 119 if (checkers[i] instanceof ForeignKeyRIChecker) 120 { 121 checkers[i].doCheck(row); 122 } 123 } 124 } 125 126 135 public void doRICheck(int index, ExecRow row, boolean restrictCheckOnly) throws StandardException 136 { 137 if (SanityManager.DEBUG) 138 { 139 if (checkers == null) 140 { 141 SanityManager.THROWASSERT("no checkers, how can i execute checker "+index); 142 } 143 144 if (index >= checkers.length) 145 { 146 SanityManager.THROWASSERT("there are only "+ 147 checkers.length+" checkers, "+index+" is invalid"); 148 } 149 } 150 151 checkers[index].doCheck(row, restrictCheckOnly); 152 } 153 154 159 public void close() throws StandardException 160 { 161 if (checkers == null) 162 return; 163 164 for (int i = 0; i < checkers.length; i++) 165 { 166 checkers[i].close(); 167 } 168 } 169 } 170 171 | Popular Tags |