KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > impl > ShortConstant


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-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 private short value;
15
16 public static Constant fromValue(short value) {
17     return new ShortConstant(value);
18 }
19 private ShortConstant(short value) {
20     this.value = value;
21 }
22 public byte byteValue() {
23     return (byte) value;
24 }
25 public char charValue() {
26     return (char) value;
27 }
28 public double doubleValue() {
29     return value; // implicit cast to return type
30
}
31 public float floatValue() {
32     return value; // implicit cast to return type
33
}
34 public int intValue() {
35     return value; // implicit cast to return type
36
}
37 public long longValue() {
38     return value; // implicit cast to return type
39
}
40 public short shortValue() {
41     return value;
42 }
43 public String JavaDoc stringValue() {
44     //spec 15.17.11
45
return String.valueOf(this.value);
46 }
47 public String JavaDoc toString(){
48
49     return "(short)" + value ; } //$NON-NLS-1$
50
public int typeID() {
51     return T_short;
52 }
53 }
54
Popular Tags