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