Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / MyDerby-10.3 / java / engine / org / apache / derby / impl / sql / catalog / OIDTDCacheable.java
diff --git a/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/sql/catalog/OIDTDCacheable.java b/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/sql/catalog/OIDTDCacheable.java
new file mode 100644 (file)
index 0000000..15e8124
--- /dev/null
@@ -0,0 +1,150 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.sql.catalog.OIDTDCacheable\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.catalog;\r
+\r
+import org.apache.derby.iapi.services.cache.Cacheable;\r
+\r
+import org.apache.derby.iapi.sql.dictionary.TableDescriptor;\r
+\r
+import org.apache.derby.iapi.error.StandardException;\r
+\r
+import org.apache.derby.iapi.services.sanity.SanityManager;\r
+\r
+import org.apache.derby.catalog.UUID;\r
+\r
+/**\r
+ * This class implements a Cacheable for a DataDictionary cache of\r
+ * table descriptors, with the lookup key being the UUID of the table.\r
+ */\r
+class OIDTDCacheable extends TDCacheable\r
+{\r
+       private UUID    identity;\r
+\r
+       OIDTDCacheable(DataDictionaryImpl dd) {\r
+               super(dd);\r
+       }\r
+\r
+       /* Cacheable interface */\r
+\r
+       /** @see Cacheable#clearIdentity */\r
+       public void clearIdentity()\r
+       {\r
+               identity = null;\r
+               td = null;\r
+       }\r
+\r
+       /** @see Cacheable#getIdentity */\r
+       public Object getIdentity()\r
+       {\r
+               return identity;\r
+       }\r
+\r
+       /** @see Cacheable#createIdentity */\r
+       public Cacheable createIdentity(Object key, Object createParameter)\r
+       {\r
+               if (SanityManager.DEBUG)\r
+               {\r
+                       if (!(key instanceof UUID))\r
+                       {\r
+                               SanityManager.THROWASSERT("Key for an OIDTDCacheElement is a " +\r
+                                       key.getClass().getName() +\r
+                                       " instead of an UUID");\r
+                       }\r
+                       if (!(createParameter instanceof TableDescriptor))\r
+                       {\r
+                               SanityManager.THROWASSERT("Create parameter for an OIDTDCacheElement is a " +\r
+                                       createParameter.getClass().getName() +\r
+                                       "instead of a TableDescriptorImpl");\r
+                       }\r
+               }\r
+\r
+               identity = ((UUID) key).cloneMe();\r
+               td = (TableDescriptor) createParameter;\r
+\r
+               if (td != null)\r
+                       return this;\r
+               else\r
+                       return null;\r
+       }\r
+\r
+       /**\r
+        * @see Cacheable#setIdentity\r
+        *\r
+        * @exception StandardException         Thrown on error\r
+        */\r
+       public Cacheable setIdentity(Object key) throws StandardException\r
+       {\r
+               if (SanityManager.DEBUG)\r
+               {\r
+                       if (!(key instanceof UUID))\r
+                       {\r
+                               SanityManager.THROWASSERT("Key for an OIDTDCacheElement is a " +\r
+                                       key.getClass().getName() +\r
+                                       " instead of an UUID");\r
+                       }\r
+               }\r
+\r
+               identity = ((UUID) key).cloneMe();\r
+               td = dd.getUncachedTableDescriptor(identity);\r
+\r
+               if (td != null)\r
+               {\r
+                       // Add cache entry to the nameTdCache in the DataDictionary.\r
+                       dd.addTableDescriptorToOtherCache(td, this);\r
+                       return this;\r
+               }\r
+               else\r
+                       return null;\r
+       }\r
+\r
+       /**\r
+         @exception StandardException          Thrown on error\r
+         */\r
+       // If this code is required it should be moved into a D_ class. - djd\r
+       /*\r
+       public boolean isConsistent(HeaderPrintWriter reportInconsistent)\r
+               throws StandardException\r
+       {\r
+               boolean retval = true;\r
+\r
+               if (SanityManager.DEBUG)\r
+               {\r
+                       TableDescriptor uncachedTD;\r
+\r
+                       try\r
+                       {\r
+                               uncachedTD = dd.getUncachedTableDescriptor(identity);\r
+                       }\r
+                       catch (StandardException se)\r
+                       {\r
+                               reportInconsistent.println("Unexpected exception " + se +\r
+                                 " while getting cached table descriptor in OIDTDCacheable.");\r
+                               uncachedTD = null;\r
+                       }\r
+\r
+                       retval = checkConsistency(uncachedTD, identity, reportInconsistent);\r
+               }\r
+\r
+               return retval;\r
+       }\r
+       */\r
+}\r