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/CharValueImpl.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.CharValue;
29
import com.sun.jdi.InvalidTypeException;
30
import com.sun.jdi.Type;
31
import com.sun.jdi.VirtualMachine;
32
33
public class CharValueImpl extends PrimitiveValueImpl
34
implements CharValue
35
{
36
private char value;
37
38
CharValueImpl(VirtualMachine aVm, char aValue) {
39
super(aVm);
40
value = aValue;
41
}
42
43
public boolean equals(Object obj) {
44
if ((obj != null) && (obj instanceof CharValue)) {
45
return (value == ((CharValue)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(CharValue obj) {
60
char other = obj.value();
61
return value() - other;
62
}
63
64
public Type type() {
65
return vm.theCharType();
66
}
67
68
public char value() {
69
return value;
70
}
71
72
public boolean booleanValue() {
73
return (value == 0 ? false : true);
74
}
75
76
public byte byteValue() {
77
return (byte)value;
78
}
79
80
public char charValue() {
81
return value;
82
}
83
84
public short shortValue() {
85
return (short)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
public String toString() {
105
return "" + value;
106
}
107
108
byte checkedByteValue() throws InvalidTypeException {
109
// Note: since char is unsigned, don't check against MIN_VALUE
110
if (value > Byte.MAX_VALUE) {
111
throw new InvalidTypeException("Can't convert " + value + " to byte");
112
} else {
113
return super.checkedByteValue();
114
}
115
}
116
117
short checkedShortValue() throws InvalidTypeException {
118
// Note: since char is unsigned, don't check against MIN_VALUE
119
if (value > Short.MAX_VALUE) {
120
throw new InvalidTypeException("Can't convert " + value + " to short");
121
} else {
122
return super.checkedShortValue();
123
}
124
}
125
126
byte typeValueKey() {
127
return JDWP.Tag.CHAR;
128
}
129
}
130
131