KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jas > NameTypeCP


1 /**
2  * Create a name/type entry constant pool entry
3  *
4  * @author $Author: fqian $
5  * @version $Revision: 1.1 $
6  */

7
8 package jas;
9
10 import java.io.*;
11
12
13 public class NameTypeCP extends CP implements RuntimeConstants
14 {
15   AsciiCP name, sig;
16
17   /**
18    * Name/type entries are used to specify the type associated
19    * with a symbol name.
20    *
21    * @param name Name of symbol
22    * @param sig Signature of symbol
23    */

24   public NameTypeCP(String JavaDoc name, String JavaDoc sig)
25   {
26     uniq = ("NT : @#$%" + name + "SD#$"+ sig).intern();
27     this.name = new AsciiCP(name);
28     this.sig = new AsciiCP(sig);
29   }
30
31   void resolve(ClassEnv e)
32   {
33     e.addCPItem(name);
34     e.addCPItem(sig);
35   }
36     
37   void write(ClassEnv e, DataOutputStream out)
38     throws IOException, jasError
39   {
40     out.writeByte(CONSTANT_NAMEANDTYPE);
41     out.writeShort(e.getCPIndex(name));
42     out.writeShort(e.getCPIndex(sig));
43   }
44 }
45
Popular Tags