1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.jdo.impl.enhancer.classfile;
20
21 import java.io.*;
22 import java.util.Stack;
23
24 /***
25 * Abstract base class of the types which represent entries in
26 * the class constant pool.
27 */
28 abstract public class ConstBasic implements VMConstants {
29
30 protected int index = 0;
31
32
33
34
35 public int getIndex() { return index; }
36
37
38 public abstract int tag();
39
40 /* package local methods *//package-summary/html">class="comment"> package local methods *//package-summary.html">
41
42 /***
43 * Sets the index of this constant with its containing constant pool
44 */
45 void setIndex(int ind) { index = ind; }
46
47 /***
48 * Write this Constant pool entry to the output stream
49 */
50 abstract void formatData(DataOutputStream b) throws IOException;
51
52 /***
53 * Resolve integer index references to the actual constant pool
54 * entries that they represent. This is used during class file
55 * reading because a constant pool entry could have a forward
56 * reference to a higher numbered constant.
57 */
58 abstract void resolve(ConstantPool p);
59
60 /***
61 * Return the index of this constant in the constant pool as
62 * a decimal formatted String.
63 */
64 String indexAsString() { return Integer.toString(index); }
65
66 /***
67 * The constructor for subtypes
68 */
69 ConstBasic() {}
70
71 /***
72 * Compares this instance with another for structural equality.
73 */
74
75 public boolean isEqual(Stack msg, Object obj) {
76 if (!(obj instanceof ConstBasic)) {
77 msg.push("obj/obj.getClass() = "
78 + (obj == null ? null : obj.getClass()));
79 msg.push("this.getClass() = "
80 + this.getClass());
81 return false;
82 }
83 ConstBasic other = (ConstBasic)obj;
84
85 return true;
86 }
87 }