1 21 22 package org.apache.derby.iapi.services.classfile; 23 24 import java.lang.reflect.Modifier ; 25 26 import java.io.IOException ; 27 28 29 30 public class ClassMember { 31 protected ClassHolder cpt; 32 protected int access_flags; 33 protected int name_index; 34 protected int descriptor_index; 35 protected Attributes attribute_info; 37 ClassMember(ClassHolder cpt, int modifier, int name, int descriptor) { 38 this.cpt = cpt; 39 name_index = name; 40 descriptor_index = descriptor; 41 access_flags = modifier; 42 } 43 44 47 48 public int getModifier() { 49 return access_flags; 50 } 51 52 public String getDescriptor() { 53 return cpt.nameIndexToString(descriptor_index); 54 } 55 56 public String getName() { 57 return cpt.nameIndexToString(name_index); 58 } 59 60 public void addAttribute(String attributeName, ClassFormatOutput info) { 61 62 if (attribute_info == null) 63 attribute_info = new Attributes(1); 64 65 attribute_info.addEntry(new AttributeEntry(cpt.addUtf8(attributeName), info)); 66 } 67 68 69 72 73 void put(ClassFormatOutput out) throws IOException { 74 out.putU2(access_flags); 75 out.putU2(name_index); 76 out.putU2(descriptor_index); 77 78 if (attribute_info != null) { 79 out.putU2(attribute_info.size()); 80 attribute_info.put(out); 81 } else { 82 out.putU2(0); 83 } 84 } 85 86 int classFileSize() { 87 int size = 2 + 2 + 2 + 2; 88 if (attribute_info != null) 89 size += attribute_info.classFileSize(); 90 return size; 91 } 92 } 93 | Popular Tags |