1 15 16 package javassist.bytecode.annotation; 17 18 import javassist.bytecode.ConstPool; 19 import javassist.bytecode.Descriptor; 20 import java.io.IOException ; 21 22 28 public class EnumMemberValue extends MemberValue { 29 int typeIndex, valueIndex; 30 31 40 public EnumMemberValue(int type, int value, ConstPool cp) { 41 super('e', cp); 42 this.typeIndex = type; 43 this.valueIndex = value; 44 } 45 46 50 public EnumMemberValue(ConstPool cp) { 51 super('e', cp); 52 typeIndex = valueIndex = 0; 53 } 54 55 60 public String getType() { 61 return Descriptor.toClassName(cp.getUtf8Info(typeIndex)); 62 } 63 64 69 public void setType(String typename) { 70 typeIndex = cp.addUtf8Info(Descriptor.of(typename)); 71 } 72 73 76 public String getValue() { 77 return cp.getUtf8Info(valueIndex); 78 } 79 80 83 public void setValue(String name) { 84 valueIndex = cp.addUtf8Info(name); 85 } 86 87 public String toString() { 88 return getType() + "." + getValue(); 89 } 90 91 void write(AnnotationsWriter writer) throws IOException { 92 writer.enumConstValue(getType(), getValue()); 93 } 94 95 98 public void accept(MemberValueVisitor visitor) { 99 visitor.visitEnumMemberValue(this); 100 } 101 } 102 | Popular Tags |