Path: blob/master/src/jdk.jdi/share/classes/com/sun/tools/jdi/ByteValueImpl.java
41161 views
/*1* Copyright (c) 1998, 2017, 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.ByteValue;28import com.sun.jdi.InvalidTypeException;29import com.sun.jdi.Type;30import com.sun.jdi.VirtualMachine;3132public class ByteValueImpl extends PrimitiveValueImpl33implements ByteValue34{35private byte value;3637ByteValueImpl(VirtualMachine aVm, byte aValue) {38super(aVm);39value = aValue;40}4142public boolean equals(Object obj) {43if ((obj != null) && (obj instanceof ByteValue)) {44return (value == ((ByteValue)obj).value())45&& super.equals(obj);46} else {47return false;48}49}5051public int hashCode() {52/*53* TO DO: Better hash code54*/55return intValue();56}5758public int compareTo(ByteValue obj) {59byte other = obj.value();60return value() - other;61}6263public Type type() {64return vm.theByteType();65}6667public byte value() {68return value;69}7071public boolean booleanValue() {72return (value == 0 ? false : true);73}7475public byte byteValue() {76return value;77}7879public char charValue() {80return (char)value;81}8283public short shortValue() {84return value;85}8687public int intValue() {88return value;89}9091public long longValue() {92return value;93}9495public float floatValue() {96return value;97}9899public double doubleValue() {100return value;101}102103char checkedCharValue() throws InvalidTypeException {104if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {105throw new InvalidTypeException("Can't convert " + value + " to char");106} else {107return super.checkedCharValue();108}109}110111public String toString() {112return "" + value;113}114115byte typeValueKey() {116return JDWP.Tag.BYTE;117}118}119120121