001 package serp.bytecode.lowlevel; 002 003 import java.io.*; 004 005 import serp.bytecode.visitor.*; 006 007 /** 008 * A constant double value in the constant pool. 009 * 010 * @author Abe White 011 */ 012 public class DoubleEntry extends Entry implements ConstantEntry { 013 private double _value = 0.0; 014 015 /** 016 * Default constructor. 017 */ 018 public DoubleEntry() { 019 } 020 021 /** 022 * Constructor. 023 * 024 * @param value the constant double value of this entry 025 */ 026 public DoubleEntry(double value) { 027 _value = value; 028 } 029 030 public boolean isWide() { 031 return true; 032 } 033 034 public int getType() { 035 return Entry.DOUBLE; 036 } 037 038 /** 039 * Return the value of the constant. 040 */ 041 public double getValue() { 042 return _value; 043 } 044 045 /** 046 * Set the value of the constant. 047 */ 048 public void setValue(double value) { 049 Object key = beforeModify(); 050 _value = value; 051 afterModify(key); 052 } 053 054 public Object getConstant() { 055 return new Double(getValue()); 056 } 057 058 public void setConstant(Object value) { 059 setValue(((Number) value).doubleValue()); 060 } 061 062 public void acceptVisit(BCVisitor visit) { 063 visit.enterDoubleEntry(this); 064 visit.exitDoubleEntry(this); 065 } 066 067 void readData(DataInput in) throws IOException { 068 _value = in.readDouble(); 069 } 070 071 void writeData(DataOutput out) throws IOException { 072 out.writeDouble(_value); 073 } 074 }