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