Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/tools/jdi/CharValueImpl.java
38920 views
/*1* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.tools.jdi;2627import com.sun.jdi.*;2829public class CharValueImpl extends PrimitiveValueImpl30implements CharValue {31private char value;3233CharValueImpl(VirtualMachine aVm,char aValue) {34super(aVm);3536value = aValue;37}3839public boolean equals(Object obj) {40if ((obj != null) && (obj instanceof CharValue)) {41return (value == ((CharValue)obj).value()) &&42super.equals(obj);43} else {44return false;45}46}4748public int hashCode() {49/*50* TO DO: Better hash code51*/52return intValue();53}5455public int compareTo(CharValue obj) {56char other = obj.value();57return value() - other;58}5960public Type type() {61return vm.theCharType();62}6364public char value() {65return value;66}6768public boolean booleanValue() {69return(value == 0)?false:true;70}7172public byte byteValue() {73return(byte)value;74}7576public char charValue() {77return value;78}7980public short shortValue() {81return(short)value;82}8384public int intValue() {85return(int)value;86}8788public long longValue() {89return(long)value;90}9192public float floatValue() {93return(float)value;94}9596public double doubleValue() {97return(double)value;98}99100public String toString() {101return "" + value;102}103104byte checkedByteValue() throws InvalidTypeException {105// Note: since char is unsigned, don't check against MIN_VALUE106if (value > Byte.MAX_VALUE) {107throw new InvalidTypeException("Can't convert " + value + " to byte");108} else {109return super.checkedByteValue();110}111}112113short checkedShortValue() throws InvalidTypeException {114// Note: since char is unsigned, don't check against MIN_VALUE115if (value > Short.MAX_VALUE) {116throw new InvalidTypeException("Can't convert " + value + " to short");117} else {118return super.checkedShortValue();119}120}121122byte typeValueKey() {123return JDWP.Tag.CHAR;124}125}126127128