Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/tools/jdi/FloatValueImpl.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 FloatValueImpl extends PrimitiveValueImpl30implements FloatValue {31private float value;3233FloatValueImpl(VirtualMachine aVm,float aValue) {34super(aVm);3536value = aValue;37}3839public boolean equals(Object obj) {40if ((obj != null) && (obj instanceof FloatValue)) {41return (value == ((FloatValue)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(FloatValue obj) {56float other = obj.value();57if (value() < other) {58return -1;59} else if (value() == other) {60return 0;61} else {62return 1;63}64}6566public Type type() {67return vm.theFloatType();68}6970public float value() {71return value;72}7374public boolean booleanValue() {75return(value == 0.0)?false:true;76}7778public byte byteValue() {79return(byte)value;80}8182public char charValue() {83return(char)value;84}8586public short shortValue() {87return(short)value;88}8990public int intValue() {91return(int)value;92}9394public long longValue() {95return(long)value;96}9798public float floatValue() {99return value;100}101102public double doubleValue() {103return(double)value;104}105106byte checkedByteValue() throws InvalidTypeException {107if ((value > Byte.MAX_VALUE) || (value < Byte.MIN_VALUE)) {108throw new InvalidTypeException("Can't convert " + value + " to byte");109} else {110return super.checkedByteValue();111}112}113114char checkedCharValue() throws InvalidTypeException {115if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {116throw new InvalidTypeException("Can't convert " + value + " to char");117} else {118return super.checkedCharValue();119}120}121122short checkedShortValue() throws InvalidTypeException {123if ((value > Short.MAX_VALUE) || (value < Short.MIN_VALUE)) {124throw new InvalidTypeException("Can't convert " + value + " to short");125} else {126return super.checkedShortValue();127}128}129130int checkedIntValue() throws InvalidTypeException {131int intValue = (int)value;132if (intValue != value) {133throw new InvalidTypeException("Can't convert " + value + " to int");134} else {135return super.checkedIntValue();136}137}138139long checkedLongValue() throws InvalidTypeException {140long longValue = (long)value;141if (longValue != value) {142throw new InvalidTypeException("Can't convert " + value + " to long");143} else {144return super.checkedLongValue();145}146}147148public String toString() {149return "" + value;150}151152byte typeValueKey() {153return JDWP.Tag.FLOAT;154}155}156157158