Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/tools/jdi/ByteValueImpl.java
38920 views
/*1* Copyright (c) 1998, 2004, 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 ByteValueImpl extends PrimitiveValueImpl30implements ByteValue {31private byte value;3233ByteValueImpl(VirtualMachine aVm,byte aValue) {34super(aVm);3536value = aValue;37}3839public boolean equals(Object obj) {40if ((obj != null) && (obj instanceof ByteValue)) {41return (value == ((ByteValue)obj).value())42&& super.equals(obj);43} else {44return false;45}46}4748public int hashCode() {49/*50* TO DO: Better hash code51*/52return intValue();53}5455public int compareTo(ByteValue obj) {56byte other = obj.value();57return value() - other;58}596061public Type type() {62return vm.theByteType();63}6465public byte value() {66return value;67}6869public boolean booleanValue() {70return(value == 0)?false:true;71}7273public byte byteValue() {74return value;75}7677public char charValue() {78return(char)value;79}8081public short shortValue() {82return(short)value;83}8485public int intValue() {86return(int)value;87}8889public long longValue() {90return(long)value;91}9293public float floatValue() {94return(float)value;95}9697public double doubleValue() {98return(double)value;99}100101char checkedCharValue() throws InvalidTypeException {102if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {103throw new InvalidTypeException("Can't convert " + value + " to char");104} else {105return super.checkedCharValue();106}107}108109public String toString() {110return "" + value;111}112113byte typeValueKey() {114return JDWP.Tag.BYTE;115}116}117118119