Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / derby-10.3.2.1 / java / engine / org / apache / derby / impl / sql / execute / TriggerEvent.java
diff --git a/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/impl/sql/execute/TriggerEvent.java b/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/impl/sql/execute/TriggerEvent.java
new file mode 100644 (file)
index 0000000..05e869b
--- /dev/null
@@ -0,0 +1,117 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.sql.execute.TriggerEvent\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.impl.sql.execute;\r
+\r
+/**\r
+ * This is a simple class that we use to track\r
+ * trigger events.  This is not expected to\r
+ * be used directly, instead there is a static\r
+ * TriggerEvent in TriggerEvents for each event \r
+ * found in this file.\r
+ * \r
+ */\r
+public class TriggerEvent\r
+{\r
+       static final int BEFORE_INSERT = 0;     \r
+       static final int BEFORE_DELETE = 1;     \r
+       static final int BEFORE_UPDATE = 2;     \r
+       static final int LAST_BEFORE_EVENT = BEFORE_UPDATE;     \r
+       static final int AFTER_INSERT = 3;      \r
+       static final int AFTER_DELETE = 4;      \r
+       static final int AFTER_UPDATE = 5;      \r
+       static final int MAX_EVENTS = 6;\r
+\r
+       private static final String Names[] = { "BEFORE INSERT",\r
+                                                                                       "BEFORE DELETE", \r
+                                                                                       "BEFORE UPDATE", \r
+                                                                                       "AFTER INSERT", \r
+                                                                                       "AFTER DELETE", \r
+                                                                                       "AFTER UPDATE"\r
+                                                                               };\r
+\r
+       private boolean before;\r
+       private int type;\r
+\r
+       /**\r
+        * Create a trigger event of the given type\r
+        *\r
+        * @param type the type\r
+        */\r
+       TriggerEvent(int type)\r
+       {\r
+               this.type = type;\r
+               switch(type)\r
+               {\r
+                       case BEFORE_INSERT:             \r
+                       case BEFORE_DELETE:             \r
+                       case BEFORE_UPDATE:             \r
+                               before = true;\r
+                               break;\r
+\r
+                       case AFTER_INSERT:              \r
+                       case AFTER_DELETE:              \r
+                       case AFTER_UPDATE:              \r
+                               before = false;\r
+                               break;\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Get the type number of this trigger\r
+        *\r
+        * @return the type number\r
+        */\r
+       int getNumber()\r
+       {\r
+               return type;\r
+       }\r
+\r
+       /**\r
+        * Get the type number of this trigger\r
+        *\r
+        * @return the type number\r
+        */\r
+       String getName()\r
+       {\r
+               return Names[type];\r
+       }\r
+\r
+       /**\r
+        * Is this a before trigger\r
+        *\r
+        * @return true if before\r
+        */\r
+       boolean isBefore()\r
+       {\r
+               return before;\r
+       }\r
+\r
+       /**\r
+        * Is this an after trigger\r
+        *\r
+        * @return true if after\r
+        */\r
+       boolean isAfter()\r
+       {\r
+               return !before;\r
+       }\r
+}      \r