View Javadoc

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