1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.bcel.generic;
20
21 import java.io.DataOutputStream;
22 import java.io.IOException;
23
24 import org.apache.bcel.classfile.AnnotationElementValue;
25 import org.apache.bcel.classfile.ElementValue;
26
27
28
29
30 public class AnnotationElementValueGen extends ElementValueGen {
31
32 private final AnnotationEntryGen a;
33
34 public AnnotationElementValueGen(final AnnotationElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) {
35 super(ANNOTATION, cpool);
36 a = new AnnotationEntryGen(value.getAnnotationEntry(), cpool, copyPoolEntries);
37 }
38
39 public AnnotationElementValueGen(final AnnotationEntryGen a, final ConstantPoolGen cpool) {
40 super(ANNOTATION, cpool);
41 this.a = a;
42 }
43
44 public AnnotationElementValueGen(final int type, final AnnotationEntryGen annotation, final ConstantPoolGen cpool) {
45 super(type, cpool);
46 if (type != ANNOTATION) {
47 throw new IllegalArgumentException("Only element values of type annotation can be built with this ctor - type specified: " + type);
48 }
49 this.a = annotation;
50 }
51
52 @Override
53 public void dump(final DataOutputStream dos) throws IOException {
54 dos.writeByte(super.getElementValueType());
55 a.dump(dos);
56 }
57
58 public AnnotationEntryGen getAnnotation() {
59 return a;
60 }
61
62
63
64
65 @Override
66 public ElementValue getElementValue() {
67 return new AnnotationElementValue(super.getElementValueType(), a.getAnnotation(), getConstantPool().getConstantPool());
68 }
69
70 @Override
71 public String stringifyValue() {
72 throw new UnsupportedOperationException("Not implemented yet");
73 }
74 }