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 public final class PMGClass extends Attribute {
33
34 private int pmgClassIndex;
35 private int pmgIndex;
36
37
38
39
40
41
42
43
44
45
46 PMGClass(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
47 this(nameIndex, length, input.readUnsignedShort(), input.readUnsignedShort(), constantPool);
48 }
49
50
51
52
53
54
55
56
57 public PMGClass(final int nameIndex, final int length, final int pmgIndex, final int pmgClassIndex, final ConstantPool constantPool) {
58 super(Const.ATTR_PMG, nameIndex, length, constantPool);
59 this.pmgIndex = pmgIndex;
60 this.pmgClassIndex = pmgClassIndex;
61 }
62
63
64
65
66
67
68
69 public PMGClass(final PMGClass pgmClass) {
70 this(pgmClass.getNameIndex(), pgmClass.getLength(), pgmClass.getPMGIndex(), pgmClass.getPMGClassIndex(), pgmClass.getConstantPool());
71 }
72
73
74
75
76
77
78
79 @Override
80 public void accept(final Visitor v) {
81 println("Visiting non-standard PMGClass object");
82 }
83
84
85
86
87 @Override
88 public Attribute copy(final ConstantPool constantPool) {
89 return (Attribute) clone();
90 }
91
92
93
94
95
96
97
98 @Override
99 public void dump(final DataOutputStream file) throws IOException {
100 super.dump(file);
101 file.writeShort(pmgIndex);
102 file.writeShort(pmgClassIndex);
103 }
104
105
106
107
108 public int getPMGClassIndex() {
109 return pmgClassIndex;
110 }
111
112
113
114
115 public String getPMGClassName() {
116 return super.getConstantPool().getConstantUtf8(pmgClassIndex).getBytes();
117 }
118
119
120
121
122 public int getPMGIndex() {
123 return pmgIndex;
124 }
125
126
127
128
129 public String getPMGName() {
130 return super.getConstantPool().getConstantUtf8(pmgIndex).getBytes();
131 }
132
133
134
135
136 public void setPMGClassIndex(final int pmgClassIndex) {
137 this.pmgClassIndex = pmgClassIndex;
138 }
139
140
141
142
143 public void setPMGIndex(final int pmgIndex) {
144 this.pmgIndex = pmgIndex;
145 }
146
147
148
149
150 @Override
151 public String toString() {
152 return "PMGClass(" + getPMGName() + ", " + getPMGClassName() + ")";
153 }
154 }