1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.bcel.classfile;
19
20 import java.io.DataInput;
21 import java.io.DataOutputStream;
22 import java.io.IOException;
23
24 import org.apache.bcel.Const;
25
26
27
28
29
30
31
32
33
34
35
36 public class MethodParameter implements Cloneable, Node {
37
38
39 private int nameIndex;
40
41
42 private int accessFlags;
43
44 public MethodParameter() {
45 }
46
47
48
49
50
51
52
53
54 MethodParameter(final DataInput input) throws IOException {
55 nameIndex = input.readUnsignedShort();
56 accessFlags = input.readUnsignedShort();
57 }
58
59 @Override
60 public void accept(final Visitor v) {
61 v.visitMethodParameter(this);
62 }
63
64
65
66
67 public MethodParameter copy() {
68 try {
69 return (MethodParameter) clone();
70 } catch (final CloneNotSupportedException e) {
71
72 }
73 return null;
74 }
75
76
77
78
79
80
81
82 public final void dump(final DataOutputStream file) throws IOException {
83 file.writeShort(nameIndex);
84 file.writeShort(accessFlags);
85 }
86
87 public int getAccessFlags() {
88 return accessFlags;
89 }
90
91 public int getNameIndex() {
92 return nameIndex;
93 }
94
95
96
97
98
99
100
101 public String getParameterName(final ConstantPool constantPool) {
102 if (nameIndex == 0) {
103 return null;
104 }
105 return constantPool.getConstantUtf8(nameIndex).getBytes();
106 }
107
108 public boolean isFinal() {
109 return (accessFlags & Const.ACC_FINAL) != 0;
110 }
111
112 public boolean isMandated() {
113 return (accessFlags & Const.ACC_MANDATED) != 0;
114 }
115
116 public boolean isSynthetic() {
117 return (accessFlags & Const.ACC_SYNTHETIC) != 0;
118 }
119
120 public void setAccessFlags(final int accessFlags) {
121 this.accessFlags = accessFlags;
122 }
123
124 public void setNameIndex(final int nameIndex) {
125 this.nameIndex = nameIndex;
126 }
127 }