1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jdo.impl.enhancer.classfile;
19
20 import java.io.*;
21 import java.util.Stack;
22
23 /***
24 * Class representing a utf8 string value in the constant pool
25 */
26 public class ConstUtf8 extends ConstBasic {
27
28 public static final int MyTag = CONSTANTUtf8;
29
30
31 private String stringValue;
32
33
34
35 /***
36 * The tag of this constant entry
37 */
38 public int tag () { return MyTag; }
39
40 /***
41 * return the value associated with the entry
42 */
43 public String asString () {
44 return stringValue;
45 }
46
47 /***
48 * A printable representation
49 */
50 public String toString () {
51 return "CONSTANTUtf8(" + indexAsString() + "): " + asString();
52 }
53
54 /***
55 * Compares this instance with another for structural equality.
56 */
57
58 public boolean isEqual(Stack msg, Object obj) {
59 if (!(obj instanceof ConstUtf8)) {
60 msg.push("obj/obj.getClass() = "
61 + (obj == null ? null : obj.getClass()));
62 msg.push("this.getClass() = "
63 + this.getClass());
64 return false;
65 }
66 ConstUtf8 other = (ConstUtf8)obj;
67
68 if (!super.isEqual(msg, other)) {
69 return false;
70 }
71
72 if (!this.stringValue.equals(other.stringValue)) {
73 msg.push(String.valueOf("stringValue = "
74 + other.stringValue));
75 msg.push(String.valueOf("stringValue = "
76 + this.stringValue));
77 return false;
78 }
79 return true;
80 }
81
82 /* package local methods *//package-summary/html">class="comment"> package local methods *//package-summary.html">
83
84 ConstUtf8 (String s) {
85 stringValue = s;
86 }
87
88 void formatData (DataOutputStream b) throws IOException {
89 b.writeUTF(stringValue);
90 }
91
92 static ConstUtf8 read (DataInputStream input) throws IOException {
93 return new ConstUtf8 (input.readUTF());
94 }
95
96 void resolve (ConstantPool p) {
97 }
98 }
99
100