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