Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / MyDerby-10.3 / java / engine / org / apache / derby / impl / sql / CursorTableReference.java
diff --git a/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/sql/CursorTableReference.java b/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/sql/CursorTableReference.java
new file mode 100644 (file)
index 0000000..240bba4
--- /dev/null
@@ -0,0 +1,170 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.sql.CursorTableReference\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;\r
+\r
+import org.apache.derby.iapi.sql.execute.ExecCursorTableReference;\r
+import org.apache.derby.iapi.services.sanity.SanityManager;\r
+\r
+import org.apache.derby.iapi.services.io.StoredFormatIds;\r
+import org.apache.derby.iapi.services.io.FormatIdUtil;\r
+import org.apache.derby.iapi.services.io.Formatable;\r
+\r
+import java.io.ObjectOutput;\r
+import java.io.ObjectInput;\r
+import java.io.IOException;\r
+/**\r
+ * \r
+ */\r
+public class CursorTableReference\r
+       implements ExecCursorTableReference, Formatable\r
+{\r
+\r
+       /********************************************************\r
+       **\r
+       **      This class implements Formatable. That means that it\r
+       **      can write itself to and from a formatted stream. If\r
+       **      you add more fields to this class, make sure that you\r
+       **      also write/read them with the writeExternal()/readExternal()\r
+       **      methods.\r
+       **\r
+       **      If, inbetween releases, you add more fields to this class,\r
+       **      then you should bump the version number emitted by the getTypeFormatId()\r
+       **      method.\r
+       **\r
+       ********************************************************/\r
+\r
+       private String          exposedName;\r
+       private String          baseName;\r
+       private String          schemaName;\r
+\r
+       /**\r
+        * Niladic constructor for Formatable\r
+        */\r
+       public CursorTableReference()\r
+       {\r
+       }\r
+\r
+       /**\r
+        *\r
+        */\r
+       public CursorTableReference\r
+       (\r
+               String  exposedName,\r
+               String  baseName,\r
+               String  schemaName\r
+       )\r
+       {\r
+               this.exposedName = exposedName;\r
+               this.baseName = baseName;\r
+               this.schemaName = schemaName;\r
+       }\r
+\r
+       /**\r
+        * Return the base name of the table\r
+        *\r
+        * @return the base name\r
+        */\r
+       public String getBaseName()\r
+       {\r
+               return baseName;\r
+       }\r
+\r
+       /**\r
+        * Return the exposed name of the table.  Exposed\r
+        * name is another term for correlation name.  If\r
+        * there is no correlation, this will return the base\r
+        * name.\r
+        *\r
+        * @return the base name\r
+        */\r
+       public String getExposedName()\r
+       {\r
+               return exposedName;\r
+       }\r
+\r
+       /**\r
+        * Return the schema for the table.  \r
+        *\r
+        * @return the schema name\r
+        */\r
+       public String getSchemaName()\r
+       {\r
+               return schemaName;\r
+       }\r
+\r
+       //////////////////////////////////////////////\r
+       //\r
+       // FORMATABLE\r
+       //\r
+       //////////////////////////////////////////////\r
+       /**\r
+        * Write this object out\r
+        *\r
+        * @param out write bytes here\r
+        *\r
+        * @exception IOException thrown on error\r
+        */\r
+       public void writeExternal(ObjectOutput out) throws IOException\r
+       {\r
+               out.writeObject(baseName);\r
+               out.writeObject(exposedName);\r
+               out.writeObject(schemaName);\r
+       }\r
+\r
+       /**\r
+        * Read this object from a stream of stored objects.\r
+        *\r
+        * @param in read this.\r
+        *\r
+        * @exception IOException                                       thrown on error\r
+        * @exception ClassNotFoundException            thrown on error\r
+        */\r
+       public void readExternal(ObjectInput in)\r
+               throws IOException, ClassNotFoundException\r
+       {\r
+               baseName = (String)in.readObject();\r
+               exposedName = (String)in.readObject();\r
+               schemaName = (String)in.readObject();\r
+       }\r
+       \r
+       /**\r
+        * Get the formatID which corresponds to this class.\r
+        *\r
+        *      @return the formatID of this class\r
+        */\r
+       public  int getTypeFormatId()   { return StoredFormatIds.CURSOR_TABLE_REFERENCE_V01_ID; }\r
+\r
+       public String toString()\r
+       {\r
+               if (SanityManager.DEBUG)\r
+               {\r
+                       return "CursorTableReference"+\r
+                               "\n\texposedName: "+exposedName+\r
+                               "\n\tbaseName: "+baseName+\r
+                               "\n\tschemaName: "+schemaName;\r
+               }\r
+               else\r
+               {\r
+                       return "";\r
+               }\r
+       }\r
+}\r