Source code: com/techtrader/modules/tools/bytecode/lowlevel/ClassEntry.java
1 package com.techtrader.modules.tools.bytecode.lowlevel;
2
3
4 import java.io.DataInput;
5 import java.io.DataOutput;
6 import java.io.IOException;
7
8 import com.techtrader.modules.tools.bytecode.visitor.BCVisitor;
9
10
11 /**
12 * Low-level representation of a constant pool entry describing a Class.
13 * Class entries are used to refer to the compiled class, the superclass,
14 * implemented interfaces, field types, etc. Each ClassEntry contains an
15 * index into the constant pool of the UTF8Entry that stores the class name,
16 * which is represented in internal form.
17 *
18 * @author Abe White
19 */
20 public class ClassEntry
21 implements Entry, LowLevelConstants
22 {
23 private int _nameIndex = -1;
24
25
26 /**
27 * Get the index into the constant pool of a UTF8Entry containing
28 * the class name.
29 */
30 public int getNameIndex ()
31 {
32 return _nameIndex;
33 }
34
35
36 /**
37 * Set the index into the constant pool of a UTF8Entry containing
38 * the class name.
39 */
40 public void setNameIndex (int nameIndex)
41 {
42 _nameIndex = nameIndex;
43 }
44
45
46 public int getType ()
47 {
48 return ENTRY_CLASS;
49 }
50
51
52 public void readData (DataInput in)
53 throws IOException
54 {
55 setNameIndex (in.readUnsignedShort ());
56 }
57
58
59 public void writeData (DataOutput out)
60 throws IOException
61 {
62 out.writeShort (getNameIndex ());
63 }
64
65
66 public String getKey ()
67 {
68 return getType () + "|" + getNameIndex ();
69 }
70
71
72 public void acceptVisit (BCVisitor visit)
73 {
74 visit.enterClassEntry (this);
75 visit.exitClassEntry (this);
76 }
77 }