KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > bytecode > CpoolUtf8


1 // Copyright (c) 1997 Per M.A. Bothner.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.bytecode;
5 import java.io.*;
6
7 public class CpoolUtf8 extends CpoolEntry
8 {
9   String JavaDoc string;
10
11   CpoolUtf8 () { }
12
13   CpoolUtf8 (ConstantPool cpool, int h, String JavaDoc s)
14   {
15     super (cpool, h);
16     string = s;
17   }
18
19   public int hashCode ()
20   {
21     if (hash == 0)
22       hash = string.hashCode();
23     return hash;
24   }
25
26   public final void intern () { string = string.intern(); }
27
28   public int getTag() { return 1; } // CONSTANT_CUtf8
29

30   public final String JavaDoc getString()
31   {
32     return string;
33   }
34
35   void write (DataOutputStream dstr) throws java.io.IOException JavaDoc
36   {
37     dstr.writeByte (1); // CONSTANT_Utf8
38
dstr.writeUTF (string);
39   }
40
41   public void print (ClassTypeWriter dst, int verbosity)
42   {
43     if (verbosity > 0)
44       dst.print("Utf8: ");
45     dst.printQuotedString(string);
46   }
47 };
48
Popular Tags