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/ByteValueImpl.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.ByteValue;
29
import com.sun.jdi.InvalidTypeException;
30
import com.sun.jdi.Type;
31
import com.sun.jdi.VirtualMachine;
32
33
public class ByteValueImpl extends PrimitiveValueImpl
34
implements ByteValue
35
{
36
private byte value;
37
38
ByteValueImpl(VirtualMachine aVm, byte aValue) {
39
super(aVm);
40
value = aValue;
41
}
42
43
public boolean equals(Object obj) {
44
if ((obj != null) && (obj instanceof ByteValue)) {
45
return (value == ((ByteValue)obj).value())
46
&& super.equals(obj);
47
} else {
48
return false;
49
}
50
}
51
52
public int hashCode() {
53
/*
54
* TO DO: Better hash code
55
*/
56
return intValue();
57
}
58
59
public int compareTo(ByteValue obj) {
60
byte other = obj.value();
61
return value() - other;
62
}
63
64
public Type type() {
65
return vm.theByteType();
66
}
67
68
public byte value() {
69
return value;
70
}
71
72
public boolean booleanValue() {
73
return (value == 0 ? false : true);
74
}
75
76
public byte byteValue() {
77
return value;
78
}
79
80
public char charValue() {
81
return (char)value;
82
}
83
84
public short shortValue() {
85
return value;
86
}
87
88
public int intValue() {
89
return value;
90
}
91
92
public long longValue() {
93
return value;
94
}
95
96
public float floatValue() {
97
return value;
98
}
99
100
public double doubleValue() {
101
return value;
102
}
103
104
char checkedCharValue() throws InvalidTypeException {
105
if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {
106
throw new InvalidTypeException("Can't convert " + value + " to char");
107
} else {
108
return super.checkedCharValue();
109
}
110
}
111
112
public String toString() {
113
return "" + value;
114
}
115
116
byte typeValueKey() {
117
return JDWP.Tag.BYTE;
118
}
119
}
120
121