1 15 16 package javassist.bytecode.annotation; 17 18 import javassist.bytecode.ConstPool; 19 import java.io.IOException ; 20 21 27 public class StringMemberValue extends MemberValue { 28 int valueIndex; 29 30 36 public StringMemberValue(int index, ConstPool cp) { 37 super('s', cp); 38 this.valueIndex = index; 39 } 40 41 46 public StringMemberValue(String str, ConstPool cp) { 47 super('s', cp); 48 setValue(str); 49 } 50 51 54 public StringMemberValue(ConstPool cp) { 55 super('s', cp); 56 setValue(""); 57 } 58 59 62 public String getValue() { 63 return cp.getUtf8Info(valueIndex); 64 } 65 66 69 public void setValue(String newValue) { 70 valueIndex = cp.addUtf8Info(newValue); 71 } 72 73 76 public String toString() { 77 return "\"" + getValue() + "\""; 78 } 79 80 void write(AnnotationsWriter writer) throws IOException { 81 writer.constValueIndex(getValue()); 82 } 83 84 87 public void accept(MemberValueVisitor visitor) { 88 visitor.visitStringMemberValue(this); 89 } 90 } 91 | Popular Tags |