1 package serp.bytecode.lowlevel;
2
3 import java.io.*;
4
5 import serp.bytecode.visitor.*;
6
7
8
9
10
11
12
13 public class NameAndTypeEntry extends Entry {
14 private int _nameIndex = 0;
15 private int _descriptorIndex = 0;
16
17
18
19
20 public NameAndTypeEntry() {
21 }
22
23
24
25
26
27
28
29
30
31 public NameAndTypeEntry(int nameIndex, int descriptorIndex) {
32 _nameIndex = nameIndex;
33 _descriptorIndex = descriptorIndex;
34 }
35
36 public int getType() {
37 return Entry.NAMEANDTYPE;
38 }
39
40
41
42
43
44 public int getNameIndex() {
45 return _nameIndex;
46 }
47
48
49
50
51
52 public void setNameIndex(int nameIndex) {
53 Object key = beforeModify();
54 _nameIndex = nameIndex;
55 afterModify(key);
56 }
57
58
59
60
61
62 public UTF8Entry getNameEntry() {
63 return (UTF8Entry) getPool().getEntry(_nameIndex);
64 }
65
66
67
68
69
70 public int getDescriptorIndex() {
71 return _descriptorIndex;
72 }
73
74
75
76
77
78 public void setDescriptorIndex(int descriptorIndex) {
79 Object key = beforeModify();
80 _descriptorIndex = descriptorIndex;
81 afterModify(key);
82 }
83
84
85
86
87
88 public UTF8Entry getDescriptorEntry() {
89 return (UTF8Entry) getPool().getEntry(_descriptorIndex);
90 }
91
92 public void acceptVisit(BCVisitor visit) {
93 visit.enterNameAndTypeEntry(this);
94 visit.exitNameAndTypeEntry(this);
95 }
96
97 void readData(DataInput in) throws IOException {
98 _nameIndex = in.readUnsignedShort();
99 _descriptorIndex = in.readUnsignedShort();
100 }
101
102 void writeData(DataOutput out) throws IOException {
103 out.writeShort(_nameIndex);
104 out.writeShort(_descriptorIndex);
105 }
106 }