1 /******************************************************************************* 2 * Copyright (c) 2000, 2016 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Common Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/cpl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.jdt.internal.compiler.impl; 12 13 public class ShortConstant extends Constant { 14 short value; ShortConstant(short value)15public ShortConstant(short value) { 16 this.value = value; 17 } byteValue()18public byte byteValue() { 19 return (byte) value; 20 } charValue()21public char charValue() { 22 return (char) value; 23 } doubleValue()24public double doubleValue() { 25 return value; // implicit cast to return type 26 } floatValue()27public float floatValue() { 28 return value; // implicit cast to return type 29 } intValue()30public int intValue() { 31 return value; // implicit cast to return type 32 } longValue()33public long longValue() { 34 return value; // implicit cast to return type 35 } shortValue()36public short shortValue() { 37 return value; 38 } stringValue()39public String stringValue() { 40 //spec 15.17.11 41 42 String s = Integer.valueOf(value).toString() ; 43 if (s == null) return "null"; //$NON-NLS-1$ 44 return s; 45 } toString()46public String toString(){ 47 48 return "(short)" + value ; } //$NON-NLS-1$ typeID()49public int typeID() { 50 return T_short; 51 } 52 } 53