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