Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / MyDerby-10.3 / java / engine / org / apache / derby / impl / sql / execute / UniqueIndexSortObserver.java
diff --git a/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/sql/execute/UniqueIndexSortObserver.java b/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/sql/execute/UniqueIndexSortObserver.java
new file mode 100644 (file)
index 0000000..05cc527
--- /dev/null
@@ -0,0 +1,77 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.sql.execute.UniqueIndexSortObserver\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
+import org.apache.derby.iapi.reference.SQLState;\r
+\r
+import org.apache.derby.iapi.services.io.Storable;\r
+\r
+import org.apache.derby.iapi.error.StandardException;\r
+\r
+import org.apache.derby.iapi.store.access.SortObserver;\r
+\r
+import org.apache.derby.iapi.sql.execute.ExecRow;\r
+\r
+import org.apache.derby.iapi.types.DataValueDescriptor;\r
+\r
+/**\r
+ * Unique index aggregator.  Enforces uniqueness when\r
+ * creating a unique index or constraint.\r
+ *\r
+ */\r
+class UniqueIndexSortObserver extends BasicSortObserver \r
+{\r
+       private boolean         isConstraint;\r
+       private String          indexOrConstraintName;\r
+       private String          tableName;\r
+\r
+       public UniqueIndexSortObserver(boolean doClone, boolean isConstraint, \r
+                               String indexOrConstraintName, ExecRow execRow, \r
+                               boolean reuseWrappers, String tableName)\r
+       {\r
+               super(doClone, true, execRow, reuseWrappers);\r
+               this.isConstraint = isConstraint;\r
+               this.indexOrConstraintName = indexOrConstraintName;\r
+               this.tableName = tableName;\r
+       }\r
+\r
+       /*\r
+        * Overridden from BasicSortObserver\r
+        */\r
+\r
+       /**\r
+        * @see AggregateSortObserver#insertDuplicateKey\r
+        *\r
+        * @exception StandardException         Thrown on failure\r
+        */\r
+       public DataValueDescriptor[] insertDuplicateKey(\r
+    DataValueDescriptor[]   in, \r
+    DataValueDescriptor[]   dup)\r
+               throws StandardException\r
+       {\r
+               StandardException se = null;\r
+               se = StandardException.newException(\r
+                               SQLState.LANG_DUPLICATE_KEY_CONSTRAINT, indexOrConstraintName, tableName);\r
+               throw se;\r
+       }\r
+\r
+}\r