KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jas > StringCP


1 package jas;
2
3 import java.io.*;
4
5
6 /**
7  * Wrap an String constant reference with this CPE.
8  *
9  * @author $Author: fqian $
10  * @version $Revision: 1.1 $
11  */

12
13 public class StringCP extends CP implements RuntimeConstants
14 {
15   AsciiCP val;
16
17   /**
18    * @param s Value for String constant
19    */

20   public StringCP(String JavaDoc s)
21   {
22     uniq = ("String: @#$" + s).intern();
23     val = new AsciiCP(s);
24   }
25   void resolve(ClassEnv e) { e.addCPItem(val); }
26   void write(ClassEnv e, DataOutputStream out)
27     throws IOException, jasError
28   {
29     out.writeByte(CONSTANT_STRING);
30     out.writeShort(e.getCPIndex(val));
31   }
32 }
33
Popular Tags