package com.sun.org.apache.bcel.internal.generic;
import java.io.DataOutputStream;
import java.io.IOException;
import com.sun.org.apache.bcel.internal.classfile.AnnotationElementValue;
import com.sun.org.apache.bcel.internal.classfile.ElementValue;
public class AnnotationElementValueGen extends ElementValueGen
{
private final AnnotationEntryGen a;
public AnnotationElementValueGen(final AnnotationEntryGen a, final ConstantPoolGen cpool)
{
super(ANNOTATION, cpool);
this.a = a;
}
public AnnotationElementValueGen(final int type, final AnnotationEntryGen annotation,
final ConstantPoolGen cpool)
{
super(type, cpool);
if (type != ANNOTATION) {
throw new RuntimeException(
"Only element values of type annotation can be built with this ctor - type specified: " + type);
}
this.a = annotation;
}
public AnnotationElementValueGen(final AnnotationElementValue value,
final ConstantPoolGen cpool, final boolean copyPoolEntries)
{
super(ANNOTATION, cpool);
a = new AnnotationEntryGen(value.getAnnotationEntry(), cpool, copyPoolEntries);
}
@Override
public void dump(final DataOutputStream dos) throws IOException
{
dos.writeByte(super.getElementValueType());
a.dump(dos);
}
@Override
public String stringifyValue()
{
throw new RuntimeException("Not implemented yet");
}
@Override
public ElementValue getElementValue()
{
return new AnnotationElementValue(super.getElementValueType(),
a.getAnnotation(),
getConstantPool().getConstantPool());
}
public AnnotationEntryGen getAnnotation()
{
return a;
}
}