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 * Class representing an integer constant in the constant pool of a class file
25 */
26 public class ConstInteger extends ConstValue {
27
28 public static final int MyTag = CONSTANTInteger;
29
30
31 private int intValue;
32
33
34
35 /***
36 * The tag of this constant entry
37 */
38 public int tag() { return MyTag; }
39
40 /***
41 * return the value associated with the entry
42 */
43 public int value() {
44 return intValue;
45 }
46
47 /***
48 * Return the descriptor string for the constant type.
49 */
50 public String descriptor() {
51 return "I";
52 }
53
54 /***
55 * A printable representation
56 */
57 public String toString() {
58 return "CONSTANTInteger(" + indexAsString() + "): " +
59 "intValue(" + Integer.toString(intValue) + ")";
60 }
61
62 /***
63 * Compares this instance with another for structural equality.
64 */
65
66 public boolean isEqual(Stack msg, Object obj) {
67 if (!(obj instanceof ConstInteger)) {
68 msg.push("obj/obj.getClass() = "
69 + (obj == null ? null : obj.getClass()));
70 msg.push("this.getClass() = "
71 + this.getClass());
72 return false;
73 }
74 ConstInteger other = (ConstInteger)obj;
75
76 if (!super.isEqual(msg, other)) {
77 return false;
78 }
79
80 if (this.intValue != other.intValue) {
81 msg.push(String.valueOf("intValue = "
82 + other.intValue));
83 msg.push(String.valueOf("intValue = "
84 + this.intValue));
85 return false;
86 }
87 return true;
88 }
89
90 /* package local methods *//package-summary/html">class="comment"> package local methods *//package-summary.html">
91
92 ConstInteger(int i) {
93 intValue = i;
94 }
95
96 void formatData(DataOutputStream b) throws IOException {
97 b.writeInt(intValue);
98 }
99
100 static ConstInteger read(DataInputStream input) throws IOException {
101 return new ConstInteger(input.readInt());
102 }
103
104 void resolve(ConstantPool p) { }
105 }