1 15 package javassist.bytecode.annotation; 16 17 import javassist.bytecode.ConstPool; 18 import java.io.IOException ; 19 20 26 public class ArrayMemberValue extends MemberValue { 27 MemberValue type; 28 MemberValue[] values; 29 30 33 public ArrayMemberValue(ConstPool cp) { 34 super('[', cp); 35 type = null; 36 values = null; 37 } 38 39 44 public ArrayMemberValue(MemberValue t, ConstPool cp) { 45 super('[', cp); 46 type = t; 47 values = null; 48 } 49 50 55 public MemberValue getType() { 56 return type; 57 } 58 59 62 public MemberValue[] getValue() { 63 return values; 64 } 65 66 69 public void setValue(MemberValue[] elements) { 70 values = elements; 71 if (elements != null && elements.length > 0) 72 type = elements[0]; 73 } 74 75 78 public String toString() { 79 StringBuffer buf = new StringBuffer ("{"); 80 if (values != null) { 81 for (int i = 0; i < values.length; i++) { 82 buf.append(values[i].toString()); 83 if (i + 1 < values.length) 84 buf.append(", "); 85 } 86 } 87 88 buf.append("}"); 89 return buf.toString(); 90 } 91 92 void write(AnnotationsWriter writer) throws IOException { 93 int num = values.length; 94 writer.arrayValue(num); 95 for (int i = 0; i < num; ++i) 96 values[i].write(writer); 97 } 98 99 102 public void accept(MemberValueVisitor visitor) { 103 visitor.visitArrayMemberValue(this); 104 } 105 } 106 | Popular Tags |