1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.bcel.classfile;
18
19 import java.io.DataInput;
20 import java.io.DataOutputStream;
21 import java.io.IOException;
22 import java.util.Iterator;
23 import java.util.stream.Stream;
24
25
26
27
28
29
30 public abstract class ParameterAnnotations extends Attribute implements Iterable<ParameterAnnotationEntry> {
31
32
33 private ParameterAnnotationEntry[] parameterAnnotationTable;
34
35
36
37
38
39
40
41
42 ParameterAnnotations(final byte parameterAnnotationType, final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool)
43 throws IOException {
44 this(parameterAnnotationType, nameIndex, length, (ParameterAnnotationEntry[]) null, constantPool);
45 final int numParameters = input.readUnsignedByte();
46 parameterAnnotationTable = new ParameterAnnotationEntry[numParameters];
47 for (int i = 0; i < numParameters; i++) {
48 parameterAnnotationTable[i] = new ParameterAnnotationEntry(input, constantPool);
49 }
50 }
51
52
53
54
55
56
57
58
59 public ParameterAnnotations(final byte parameterAnnotationType, final int nameIndex, final int length,
60 final ParameterAnnotationEntry[] parameterAnnotationTable, final ConstantPool constantPool) {
61 super(parameterAnnotationType, nameIndex, length, constantPool);
62 this.parameterAnnotationTable = parameterAnnotationTable;
63 }
64
65
66
67
68
69
70
71 @Override
72 public void accept(final Visitor v) {
73 v.visitParameterAnnotation(this);
74 }
75
76
77
78
79 @Override
80 public Attribute copy(final ConstantPool constantPool) {
81 return (Attribute) clone();
82 }
83
84 @Override
85 public void dump(final DataOutputStream dos) throws IOException {
86 super.dump(dos);
87 dos.writeByte(parameterAnnotationTable.length);
88
89 for (final ParameterAnnotationEntry element : parameterAnnotationTable) {
90 element.dump(dos);
91 }
92
93 }
94
95
96
97
98 public ParameterAnnotationEntry[] getParameterAnnotationEntries() {
99 return parameterAnnotationTable;
100 }
101
102
103
104
105 public final ParameterAnnotationEntry[] getParameterAnnotationTable() {
106 return parameterAnnotationTable;
107 }
108
109 @Override
110 public Iterator<ParameterAnnotationEntry> iterator() {
111 return Stream.of(parameterAnnotationTable).iterator();
112 }
113
114
115
116
117 public final void setParameterAnnotationTable(final ParameterAnnotationEntry[] parameterAnnotationTable) {
118 this.parameterAnnotationTable = parameterAnnotationTable;
119 }
120 }