KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jas > ElemValPair


1 /**
2  * ElemValPairs are embedded into class files
3  * and used for further ???
4  * @author $Author: Jennifer Lhotak$
5  * @version $Revision: 1.1 $
6  */

7
8 package jas;
9
10 import java.io.*;
11 import java.util.*;
12
13 public class ElemValPair {
14
15     AsciiCP name;
16     byte kind;
17     boolean noName;
18
19     void resolve(ClassEnv e){
20         e.addCPItem(name);
21     }
22
23     /**
24     * Note: An annotation attr is associated with a <em>class</em>,
25     * method or field so you need to create a new VisibilityAnnotationAttr for
26     */

27     public ElemValPair(String JavaDoc name, char kind) { //
28
this.name = new AsciiCP(name);
29         this.kind = (byte)kind;
30     }
31
32     int size(){
33         if (noName) return 1;
34         return 3;
35     }
36
37     public void setNoName(){
38         noName = true;
39     }
40     
41     void write(ClassEnv e, DataOutputStream out)
42         throws IOException, jasError
43         {
44    
45         if (!noName){
46             out.writeShort(e.getCPIndex(name));
47         }
48         out.writeByte(kind);
49     }
50     
51 }
52
Popular Tags