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