1 7 8 package org.gjt.jclasslib.structures; 9 10 import org.gjt.jclasslib.structures.constants.ConstantUtf8Info; 11 12 import java.io.*; 13 14 20 public abstract class ClassMember extends AbstractStructureWithAttributes 21 implements AccessFlags { 22 23 24 protected int accessFlags; 25 26 protected int nameIndex; 27 28 protected int descriptorIndex; 29 30 34 public int getAccessFlags() { 35 return accessFlags; 36 } 37 38 42 public void setAccessFlags(int accessFlags) { 43 this.accessFlags = accessFlags; 44 } 45 46 50 public int getNameIndex() { 51 return nameIndex; 52 } 53 54 58 public void setNameIndex(int nameIndex) { 59 this.nameIndex = nameIndex; 60 } 61 62 66 public int getDescriptorIndex() { 67 return descriptorIndex; 68 } 69 70 74 public void setDescriptorIndex(int descriptorIndex) { 75 this.descriptorIndex = descriptorIndex; 76 } 77 78 83 public String getName() throws InvalidByteCodeException { 84 ConstantUtf8Info cpinfo = classFile.getConstantPoolUtf8Entry(nameIndex); 85 if (cpinfo == null) { 86 return "invalid constant pool index"; 87 } else { 88 return cpinfo.getString(); 89 } 90 } 91 92 97 public String getDescriptor() throws InvalidByteCodeException { 98 ConstantUtf8Info cpinfo = classFile.getConstantPoolUtf8Entry(descriptorIndex); 99 if (cpinfo == null) { 100 return "invalid constant pool index"; 101 } else { 102 return cpinfo.getString(); 103 } 104 } 105 106 110 public String getFormattedAccessFlags() { 111 return printAccessFlags(accessFlags); 112 } 113 114 118 public String getAccessFlagsVerbose() { 119 return printAccessFlagsVerbose(accessFlags); 120 } 121 122 public void read(DataInput in) 123 throws InvalidByteCodeException, IOException { 124 125 accessFlags = in.readUnsignedShort(); 126 nameIndex = in.readUnsignedShort(); 127 descriptorIndex = in.readUnsignedShort(); 128 129 readAttributes(in); 130 131 } 132 133 public void write(DataOutput out) 134 throws InvalidByteCodeException, IOException { 135 136 out.writeShort(accessFlags); 137 out.writeShort(nameIndex); 138 out.writeShort(descriptorIndex); 139 140 writeAttributes(out); 141 } 142 143 } 144 | Popular Tags |