Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / derby-10.3.2.1 / java / engine / org / apache / derby / iapi / services / classfile / CONSTANT_Index_info.java
diff --git a/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/iapi/services/classfile/CONSTANT_Index_info.java b/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/iapi/services/classfile/CONSTANT_Index_info.java
new file mode 100644 (file)
index 0000000..251f68a
--- /dev/null
@@ -0,0 +1,92 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.iapi.services.classfile.CONSTANT_Index_info\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.iapi.services.classfile;\r
+\r
+import org.apache.derby.iapi.services.classfile.VMDescriptor;\r
+\r
+import java.io.IOException;\r
+\r
+ /**\r
+\r
+  A generic constant pool entry for entries that simply hold indexes\r
+  into other entries.\r
+\r
+  <BR>\r
+  Ref Constant Pool Entry  - page 94 - Section 4.4.2   - Two indexes\r
+  <BR>\r
+  NameAndType Constant Pool Entry  - page 99 - Section 4.4.6 - Two indexes\r
+  <BR>\r
+  String Constant Pool Entry - page 96 - Section 4.4.3 - One index\r
+  <BR>\r
+  Class Reference Constant Pool Entry - page 93 - Section 4.4.1 - One index\r
+\r
+*/\r
+public final class CONSTANT_Index_info extends ConstantPoolEntry {\r
+\r
+       private int i1;\r
+       private int i2;\r
+\r
+       CONSTANT_Index_info(int tag, int i1, int i2) {\r
+               super(tag);\r
+               this.i1 = i1;\r
+               this.i2 = i2;\r
+       }\r
+\r
+       public int hashCode() {\r
+               return (tag << 16) | ((i1 << 8) ^ i2);\r
+       }\r
+\r
+       public boolean equals(Object other) {\r
+               if (other instanceof CONSTANT_Index_info) {\r
+                       CONSTANT_Index_info o = (CONSTANT_Index_info) other;\r
+\r
+                       return (tag == o.tag) && (i1 == o.i1) && (i2 == o.i2);                  \r
+               }\r
+               return false;\r
+       }\r
+\r
+\r
+       /**\r
+               Used when searching \r
+       */\r
+       void set(int tag, int i1, int i2) {\r
+               this.tag = tag;\r
+               this.i1 = i1;\r
+               this.i2 = i2;\r
+       }\r
+\r
+       int classFileSize() {\r
+               // 1 (tag) + 2 (index length) [ + 2 (index length) ]\r
+               return 1 + 2 + ((i2 != 0) ? 2 : 0);\r
+       }\r
+\r
+       void put(ClassFormatOutput out) throws IOException {\r
+               super.put(out);\r
+               out.putU2(i1);\r
+               if (i2 != 0)\r
+                       out.putU2(i2);\r
+       }\r
+\r
+       public int getI1() { return i1; }\r
+\r
+       public int getI2() { return i2; }\r
+}\r