1 21 22 package org.apache.derby.impl.sql.execute; 23 24 33 public class TriggerEvent 34 { 35 static final int BEFORE_INSERT = 0; 36 static final int BEFORE_DELETE = 1; 37 static final int BEFORE_UPDATE = 2; 38 static final int LAST_BEFORE_EVENT = BEFORE_UPDATE; 39 static final int AFTER_INSERT = 3; 40 static final int AFTER_DELETE = 4; 41 static final int AFTER_UPDATE = 5; 42 static final int MAX_EVENTS = 6; 43 44 private static final String Names[] = { "BEFORE INSERT", 45 "BEFORE DELETE", 46 "BEFORE UPDATE", 47 "AFTER INSERT", 48 "AFTER DELETE", 49 "AFTER UPDATE" 50 }; 51 52 private boolean before; 53 private int type; 54 55 60 TriggerEvent(int type) 61 { 62 this.type = type; 63 switch(type) 64 { 65 case BEFORE_INSERT: 66 case BEFORE_DELETE: 67 case BEFORE_UPDATE: 68 before = true; 69 break; 70 71 case AFTER_INSERT: 72 case AFTER_DELETE: 73 case AFTER_UPDATE: 74 before = false; 75 break; 76 } 77 } 78 79 84 int getNumber() 85 { 86 return type; 87 } 88 89 94 String getName() 95 { 96 return Names[type]; 97 } 98 99 104 boolean isBefore() 105 { 106 return before; 107 } 108 109 114 boolean isAfter() 115 { 116 return !before; 117 } 118 } 119 | Popular Tags |