1 package serp.bytecode.lowlevel;
2
3 import java.io.*;
4
5 import serp.bytecode.visitor.*;
6
7 /***
8 * A constant double value in the constant pool.
9 *
10 * @author Abe White
11 */
12 public class DoubleEntry extends Entry implements ConstantEntry {
13 private double _value = 0.0;
14
15 /***
16 * Default constructor.
17 */
18 public DoubleEntry() {
19 }
20
21 /***
22 * Constructor.
23 *
24 * @param value the constant double value of this entry
25 */
26 public DoubleEntry(double value) {
27 _value = value;
28 }
29
30 public boolean isWide() {
31 return true;
32 }
33
34 public int getType() {
35 return Entry.DOUBLE;
36 }
37
38 /***
39 * Return the value of the constant.
40 */
41 public double getValue() {
42 return _value;
43 }
44
45 /***
46 * Set the value of the constant.
47 */
48 public void setValue(double value) {
49 Object key = beforeModify();
50 _value = value;
51 afterModify(key);
52 }
53
54 public Object getConstant() {
55 return new Double(getValue());
56 }
57
58 public void setConstant(Object value) {
59 setValue(((Number) value).doubleValue());
60 }
61
62 public void acceptVisit(BCVisitor visit) {
63 visit.enterDoubleEntry(this);
64 visit.exitDoubleEntry(this);
65 }
66
67 void readData(DataInput in) throws IOException {
68 _value = in.readDouble();
69 }
70
71 void writeData(DataOutput out) throws IOException {
72 out.writeDouble(_value);
73 }
74 }