Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/jdk.jdi/share/classes/com/sun/tools/jdi/DoubleValueImpl.java
41161 views
1
/*
2
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package com.sun.tools.jdi;
27
28
import com.sun.jdi.DoubleValue;
29
import com.sun.jdi.InvalidTypeException;
30
import com.sun.jdi.Type;
31
import com.sun.jdi.VirtualMachine;
32
33
public class DoubleValueImpl extends PrimitiveValueImpl
34
implements DoubleValue {
35
private double value;
36
37
DoubleValueImpl(VirtualMachine aVm, double aValue) {
38
super(aVm);
39
value = aValue;
40
}
41
42
public boolean equals(Object obj) {
43
if ((obj != null) && (obj instanceof DoubleValue)) {
44
return (value == ((DoubleValue)obj).value()) &&
45
super.equals(obj);
46
} else {
47
return false;
48
}
49
}
50
51
public int compareTo(DoubleValue obj) {
52
double other = obj.value();
53
if (value() < other) {
54
return -1;
55
} else if (value() == other) {
56
return 0;
57
} else {
58
return 1;
59
}
60
}
61
62
public int hashCode() {
63
/*
64
* TO DO: Better hash code
65
*/
66
return intValue();
67
}
68
69
public Type type() {
70
return vm.theDoubleType();
71
}
72
73
public double value() {
74
return value;
75
}
76
77
public boolean booleanValue() {
78
return (value == 0.0 ? false : true);
79
}
80
81
public byte byteValue() {
82
return (byte)value;
83
}
84
85
public char charValue() {
86
return (char)value;
87
}
88
89
public short shortValue() {
90
return (short)value;
91
}
92
93
public int intValue() {
94
return (int)value;
95
}
96
97
public long longValue() {
98
return (long)value;
99
}
100
101
public float floatValue() {
102
return (float)value;
103
}
104
105
public double doubleValue() {
106
return value;
107
}
108
109
byte checkedByteValue() throws InvalidTypeException {
110
if ((value > Byte.MAX_VALUE) || (value < Byte.MIN_VALUE)) {
111
throw new InvalidTypeException("Can't convert " + value + " to byte");
112
} else {
113
return super.checkedByteValue();
114
}
115
}
116
117
char checkedCharValue() throws InvalidTypeException {
118
if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {
119
throw new InvalidTypeException("Can't convert " + value + " to char");
120
} else {
121
return super.checkedCharValue();
122
}
123
}
124
125
short checkedShortValue() throws InvalidTypeException {
126
if ((value > Short.MAX_VALUE) || (value < Short.MIN_VALUE)) {
127
throw new InvalidTypeException("Can't convert " + value + " to short");
128
} else {
129
return super.checkedShortValue();
130
}
131
}
132
133
int checkedIntValue() throws InvalidTypeException {
134
if ((value > Integer.MAX_VALUE) || (value < Integer.MIN_VALUE)) {
135
throw new InvalidTypeException("Can't convert " + value + " to int");
136
} else {
137
return super.checkedIntValue();
138
}
139
}
140
141
long checkedLongValue() throws InvalidTypeException {
142
long longValue = (long)value;
143
if (longValue != value) {
144
throw new InvalidTypeException("Can't convert " + value + " to long");
145
} else {
146
return super.checkedLongValue();
147
}
148
}
149
150
float checkedFloatValue() throws InvalidTypeException {
151
float floatValue = (float)value;
152
if (floatValue != value) {
153
throw new InvalidTypeException("Can't convert " + value + " to float");
154
} else {
155
return super.checkedFloatValue();
156
}
157
}
158
159
public String toString() {
160
return "" + value;
161
}
162
163
byte typeValueKey() {
164
return JDWP.Tag.DOUBLE;
165
}
166
}
167
168