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 StringEntry extends Entry implements ConstantEntry {
14 private int _stringIndex = -1;
15
16
17
18
19 public StringEntry() {
20 }
21
22
23
24
25
26
27
28 public StringEntry(int stringIndex) {
29 _stringIndex = stringIndex;
30 }
31
32 public int getType() {
33 return Entry.STRING;
34 }
35
36
37
38
39
40 public int getStringIndex() {
41 return _stringIndex;
42 }
43
44
45
46
47
48 public void setStringIndex(int stringIndex) {
49 Object key = beforeModify();
50 _stringIndex = stringIndex;
51 afterModify(key);
52 }
53
54
55
56
57
58 public UTF8Entry getStringEntry() {
59 return (UTF8Entry) getPool().getEntry(_stringIndex);
60 }
61
62 public Object getConstant() {
63 return getStringEntry().getValue();
64 }
65
66 public void setConstant(Object value) {
67 getStringEntry().setConstant(value);
68 }
69
70 public void acceptVisit(BCVisitor visit) {
71 visit.enterStringEntry(this);
72 visit.exitStringEntry(this);
73 }
74
75 void readData(DataInput in) throws IOException {
76 _stringIndex = in.readUnsignedShort();
77 }
78
79 void writeData(DataOutput out) throws IOException {
80 out.writeShort(_stringIndex);
81 }
82 }