View Javadoc

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