1 package alt.jiapi.file; 2 3 import java.util.List ; 4 import java.util.Iterator ; 5 6 10 public class Method { 11 public static final short ACC_PUBLIC = 0x0001; 12 public static final short ACC_PRIVATE = 0x0002; 13 public static final short ACC_PROTECTED = 0x0004; 14 public static final short ACC_STATIC = 0x0008; 15 public static final short ACC_FINAL = 0x0010; 16 public static final short ACC_SYNCHRONIZED = 0x0020; 17 public static final short ACC_NATIVE = 0x0100; 18 public static final short ACC_ABSTRACT = 0x0400; 19 public static final short ACC_STRICT = 0x0800; 20 21 private ConstantPool cp; 22 private short access_flags; 23 private short name_index; 24 private short descriptor_index; 25 private List attributes; 26 27 private transient Configuration config = new Configuration(); 28 29 public Method(ConstantPool cp, short access_flags, String name, 30 String descriptor, List attributes) { 31 this.cp = cp; 32 this.access_flags = access_flags; 33 this.name_index = cp.addUtf8Info(name).getEntryIndex(); 34 this.descriptor_index = cp.addUtf8Info(descriptor).getEntryIndex(); 35 this.attributes = attributes; 36 } 37 38 Method(ConstantPool cp, short access_flags, short name_index, 39 short descriptor_index, List attributes) { 40 this.cp = cp; 41 this.access_flags = access_flags; 42 this.name_index = name_index; 43 this.descriptor_index = descriptor_index; 44 this.attributes = attributes; 45 } 46 47 48 public ConstantPool getConstantPool() { 49 return cp; 50 } 51 52 public short getAccessFlags() { 53 return access_flags; 54 } 55 56 public Attribute getAttribute(String name) { 57 Iterator i = attributes.iterator(); 58 while(i.hasNext()) { 59 Attribute a = (Attribute)i.next(); 60 if (a.getName().equals(name)) { 61 return a; 62 } 63 } 64 65 return null; 66 } 67 68 public List getAttributes() { 69 75 return attributes; 76 } 77 78 public String getName() { 79 return cp.getUtf8(name_index); 80 } 81 82 public String getDescriptor() { 83 return cp.getUtf8(descriptor_index); 84 } 85 86 short getNameIndex() { 87 return name_index; 88 } 89 90 short getDescriptorIndex() { 91 return descriptor_index; 92 } 93 } 94 95 | Popular Tags |