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