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