Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/tools/jdi/DoubleValueImpl.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 DoubleValueImpl extends PrimitiveValueImpl30implements DoubleValue {31private double value;3233DoubleValueImpl(VirtualMachine aVm,double aValue) {34super(aVm);3536value = aValue;37}3839public boolean equals(Object obj) {40if ((obj != null) && (obj instanceof DoubleValue)) {41return (value == ((DoubleValue)obj).value()) &&42super.equals(obj);43} else {44return false;45}46}4748public int compareTo(DoubleValue obj) {49double other = obj.value();50if (value() < other) {51return -1;52} else if (value() == other) {53return 0;54} else {55return 1;56}57}5859public int hashCode() {60/*61* TO DO: Better hash code62*/63return intValue();64}6566public Type type() {67return vm.theDoubleType();68}6970public double 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(float)value;100}101102public double doubleValue() {103return 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 {131if ((value > Integer.MAX_VALUE) || (value < Integer.MIN_VALUE)) {132throw new InvalidTypeException("Can't convert " + value + " to int");133} else {134return super.checkedIntValue();135}136}137138long checkedLongValue() throws InvalidTypeException {139long longValue = (long)value;140if (longValue != value) {141throw new InvalidTypeException("Can't convert " + value + " to long");142} else {143return super.checkedLongValue();144}145}146147float checkedFloatValue() throws InvalidTypeException {148float floatValue = (float)value;149if (floatValue != value) {150throw new InvalidTypeException("Can't convert " + value + " to float");151} else {152return super.checkedFloatValue();153}154}155156public String toString() {157return "" + value;158}159160byte typeValueKey() {161return JDWP.Tag.DOUBLE;162}163}164165166