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 ClassMemberValue extends MemberValue { 29 int valueIndex; 30 31 37 public ClassMemberValue(int index, ConstPool cp) { 38 super('c', cp); 39 this.valueIndex = index; 40 } 41 42 47 public ClassMemberValue(String className, ConstPool cp) { 48 super('c', cp); 49 setValue(className); 50 } 51 52 56 public ClassMemberValue(ConstPool cp) { 57 super('c', cp); 58 setValue("java.lang.Class"); 59 } 60 61 66 public String getValue() { 67 String v = cp.getUtf8Info(valueIndex); 68 return Descriptor.toClassName(v); 69 } 70 71 76 public void setValue(String newClassName) { 77 String setTo = Descriptor.of(newClassName); 78 valueIndex = cp.addUtf8Info(setTo); 79 } 80 81 84 public String toString() { 85 return "<" + getValue() + " class>"; 86 } 87 88 void write(AnnotationsWriter writer) throws IOException { 89 writer.classInfoIndex(valueIndex); 90 } 91 92 95 public void accept(MemberValueVisitor visitor) { 96 visitor.visitClassMemberValue(this); 97 } 98 } 99 | Popular Tags |