Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / MyDerby-10.3 / java / engine / org / apache / derby / iapi / services / classfile / ClassMember.java
diff --git a/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/iapi/services/classfile/ClassMember.java b/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/iapi/services/classfile/ClassMember.java
new file mode 100644 (file)
index 0000000..4d39383
--- /dev/null
@@ -0,0 +1,92 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.iapi.services.classfile.ClassMember\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 java.lang.reflect.Modifier;\r
+\r
+import java.io.IOException;\r
+\r
+\r
+\r
+public class ClassMember {\r
+       protected ClassHolder cpt;\r
+       protected int access_flags;\r
+       protected int name_index;\r
+       protected int descriptor_index;\r
+       protected Attributes attribute_info; // can be null\r
+\r
+       ClassMember(ClassHolder cpt, int modifier, int name, int descriptor) {\r
+               this.cpt = cpt;\r
+               name_index = name;\r
+               descriptor_index = descriptor;\r
+               access_flags = modifier;\r
+       }\r
+\r
+       /*\r
+       ** Public methods from ClassMember\r
+       */\r
+\r
+    public int getModifier() {\r
+                       return access_flags;\r
+       }\r
+\r
+    public String getDescriptor() {\r
+               return cpt.nameIndexToString(descriptor_index);\r
+       }\r
+       \r
+       public String getName() {\r
+               return cpt.nameIndexToString(name_index);\r
+       }\r
+\r
+       public void addAttribute(String attributeName, ClassFormatOutput info) {\r
+\r
+               if (attribute_info == null)\r
+                       attribute_info = new Attributes(1);\r
+\r
+               attribute_info.addEntry(new AttributeEntry(cpt.addUtf8(attributeName), info));\r
+       }\r
+\r
+\r
+       /*\r
+       **       ----\r
+       */\r
+\r
+       void put(ClassFormatOutput out) throws IOException {\r
+               out.putU2(access_flags);\r
+               out.putU2(name_index);\r
+               out.putU2(descriptor_index);\r
+\r
+               if (attribute_info != null) {\r
+                       out.putU2(attribute_info.size());\r
+                       attribute_info.put(out);\r
+               } else {\r
+                       out.putU2(0);\r
+               }\r
+       }\r
+\r
+       int classFileSize() {\r
+               int size = 2 + 2 + 2 + 2;\r
+               if (attribute_info != null)\r
+                       size += attribute_info.classFileSize();\r
+               return size;\r
+       }\r
+}\r