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 unicode string value in the constant pool
25 *
26 * Note: evidence suggests that this is no longer part of the java VM
27 * spec.
28 */
29 public class ConstUnicode extends ConstBasic {
30
31 public static final int MyTag = CONSTANTUnicode;
32
33
34 private String stringValue;
35
36
37
38 /***
39 * The tag of this constant entry
40 */
41 public int tag () { return MyTag; }
42
43 /***
44 * return the value associated with the entry
45 */
46 public String asString() {
47 return stringValue;
48 }
49
50 /***
51 * A printable representation
52 */
53 public String toString () {
54 return "CONSTANTUnicode(" + indexAsString() + "): " + stringValue;
55 }
56
57 /***
58 * Compares this instance with another for structural equality.
59 */
60
61 public boolean isEqual(Stack msg, Object obj) {
62 if (!(obj instanceof ConstUnicode)) {
63 msg.push("obj/obj.getClass() = "
64 + (obj == null ? null : obj.getClass()));
65 msg.push("this.getClass() = "
66 + this.getClass());
67 return false;
68 }
69 ConstUnicode other = (ConstUnicode)obj;
70
71 if (!super.isEqual(msg, other)) {
72 return false;
73 }
74
75 if (!this.stringValue.equals(other.stringValue)) {
76 msg.push(String.valueOf("stringValue = "
77 + other.stringValue));
78 msg.push(String.valueOf("stringValue = "
79 + this.stringValue));
80 return false;
81 }
82 return true;
83 }
84
85 /* package local methods *//package-summary/html">class="comment"> package local methods *//package-summary.html">
86
87 ConstUnicode (String s) {
88 stringValue = s;
89 }
90
91 void formatData (DataOutputStream b) throws IOException {
92 b.writeBytes(stringValue);
93 }
94
95 static ConstUnicode read (DataInputStream input) throws IOException {
96 int count = input.readShort();
97 StringBuffer b = new StringBuffer();
98 for (int i=0; i < count; i++) {
99 b.append(input.readChar());
100 }
101 return new ConstUnicode (b.toString());
102 }
103
104 void resolve (ConstantPool p) {
105 }
106 }