1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.bcel.classfile;
20
21 import java.io.DataInput;
22 import java.io.DataOutputStream;
23 import java.io.IOException;
24
25 import org.apache.bcel.Const;
26
27
28
29
30
31
32
33
34
35 public class RecordComponentInfo implements Node {
36
37 private final int index;
38 private final int descriptorIndex;
39 private final Attribute[] attributes;
40 private final ConstantPool constantPool;
41
42
43
44
45
46
47
48
49 public RecordComponentInfo(final DataInput input, final ConstantPool constantPool) throws IOException {
50 this.index = input.readUnsignedShort();
51 this.descriptorIndex = input.readUnsignedShort();
52 final int attributesCount = input.readUnsignedShort();
53 this.attributes = new Attribute[attributesCount];
54 for (int j = 0; j < attributesCount; j++) {
55 attributes[j] = Attribute.readAttribute(input, constantPool);
56 }
57 this.constantPool = constantPool;
58 }
59
60 @Override
61 public void accept(final Visitor v) {
62 v.visitRecordComponent(this);
63 }
64
65
66
67
68
69
70
71 public void dump(final DataOutputStream file) throws IOException {
72 file.writeShort(index);
73 file.writeShort(descriptorIndex);
74 file.writeShort(attributes.length);
75 for (final Attribute attribute : attributes) {
76 attribute.dump(file);
77 }
78 }
79
80
81
82
83
84
85 public Attribute[] getAttributes() {
86 return attributes;
87 }
88
89
90
91
92
93
94 public ConstantPool getConstantPool() {
95 return constantPool;
96 }
97
98
99
100
101
102
103 public int getDescriptorIndex() {
104 return descriptorIndex;
105 }
106
107
108
109
110
111
112 public int getIndex() {
113 return index;
114 }
115
116
117
118
119
120
121 @Override
122 public String toString() {
123 final StringBuilder buf = new StringBuilder();
124 buf.append("RecordComponentInfo(");
125 buf.append(constantPool.getConstantString(index, Const.CONSTANT_Utf8));
126 buf.append(",");
127 buf.append(constantPool.getConstantString(descriptorIndex, Const.CONSTANT_Utf8));
128 buf.append(",");
129 buf.append(attributes.length);
130 buf.append("):\n");
131 for (final Attribute attribute : attributes) {
132 buf.append(" ").append(attribute.toString()).append("\n");
133 }
134 return buf.substring(0, buf.length() - 1);
135 }
136
137 }