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