package org.aspectj.apache.bcel.classfile.annotation;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.List;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.ConstantUtf8;
public class AnnotationElementValue extends ElementValue {
private AnnotationGen a;
public AnnotationElementValue(AnnotationGen a, ConstantPool cpool) {
super(ANNOTATION, cpool);
this.a = a;
}
public AnnotationElementValue(int type, AnnotationGen annotation, ConstantPool cpool) {
super(type, cpool);
assert type == ANNOTATION;
this.a = annotation;
}
public AnnotationElementValue(AnnotationElementValue value, ConstantPool cpool, boolean copyPoolEntries) {
super(ANNOTATION, cpool);
a = new AnnotationGen(value.getAnnotation(), cpool, copyPoolEntries);
}
@Override
public void dump(DataOutputStream dos) throws IOException {
dos.writeByte(type);
a.dump(dos);
}
@Override
public String stringifyValue() {
StringBuffer sb = new StringBuffer();
ConstantUtf8 cu8 = (ConstantUtf8) cpool.getConstant(a.getTypeIndex(), Constants.CONSTANT_Utf8);
sb.append(cu8.getValue());
List<NameValuePair> pairs = a.getValues();
if (pairs != null && pairs.size() > 0) {
sb.append("(");
for (int p = 0; p < pairs.size(); p++) {
if (p > 0) {
sb.append(",");
}
sb.append(pairs.get(p).getNameString()).append("=").append(pairs.get(p).getValue().stringifyValue());
}
sb.append(")");
}
return sb.toString();
}
public AnnotationGen getAnnotation() {
return a;
}
}