1 15 package javassist.bytecode.annotation; 16 17 import javassist.bytecode.ConstPool; 18 import java.io.IOException ; 19 20 26 public class BooleanMemberValue extends MemberValue { 27 int valueIndex; 28 29 35 public BooleanMemberValue(int index, ConstPool cp) { 36 super('Z', cp); 37 this.valueIndex = index; 38 } 39 40 45 public BooleanMemberValue(boolean b, ConstPool cp) { 46 super('Z', cp); 47 setValue(b); 48 } 49 50 53 public BooleanMemberValue(ConstPool cp) { 54 super('Z', cp); 55 setValue(false); 56 } 57 58 61 public boolean getValue() { 62 return cp.getIntegerInfo(valueIndex) != 0; 63 } 64 65 68 public void setValue(boolean newValue) { 69 valueIndex = cp.addIntegerInfo(newValue ? 1 : 0); 70 } 71 72 75 public String toString() { 76 return getValue() ? "true" : "false"; 77 } 78 79 void write(AnnotationsWriter writer) throws IOException { 80 writer.constValueIndex(getValue()); 81 } 82 83 86 public void accept(MemberValueVisitor visitor) { 87 visitor.visitBooleanMemberValue(this); 88 } 89 } 90 | Popular Tags |