01: // Copyright (c) 1997 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.bytecode;
05:
06: import java.io.*;
07:
08: public class CpoolUtf8 extends CpoolEntry {
09: String string;
10:
11: CpoolUtf8() {
12: }
13:
14: CpoolUtf8(ConstantPool cpool, int h, String s) {
15: super (cpool, h);
16: string = s;
17: }
18:
19: public int hashCode() {
20: if (hash == 0)
21: hash = string.hashCode();
22: return hash;
23: }
24:
25: public final void intern() {
26: string = string.intern();
27: }
28:
29: public int getTag() {
30: return 1;
31: } // CONSTANT_CUtf8
32:
33: public final String getString() {
34: return string;
35: }
36:
37: void write(DataOutputStream dstr) throws java.io.IOException {
38: dstr.writeByte(1); // CONSTANT_Utf8
39: dstr.writeUTF(string);
40: }
41:
42: public void print(ClassTypeWriter dst, int verbosity) {
43: if (verbosity > 0)
44: dst.print("Utf8: ");
45: dst.printQuotedString(string);
46: }
47: };
|