01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.compiler.impl;
11:
12: public class LongConstant extends Constant {
13: private static final LongConstant ZERO = new LongConstant(0L);
14:
15: private long value;
16:
17: public static Constant fromValue(long value) {
18: if (value == 0L) {
19: return ZERO;
20: }
21: return new LongConstant(value);
22: }
23:
24: private LongConstant(long value) {
25: this .value = value;
26: }
27:
28: public byte byteValue() {
29: return (byte) value;
30: }
31:
32: public char charValue() {
33: return (char) value;
34: }
35:
36: public double doubleValue() {
37: return value; // implicit cast to return type
38: }
39:
40: public float floatValue() {
41: return value; // implicit cast to return type
42: }
43:
44: public int intValue() {
45: return (int) value;
46: }
47:
48: public long longValue() {
49: return value;
50: }
51:
52: public short shortValue() {
53: return (short) value;
54: }
55:
56: public String stringValue() {
57: //spec 15.17.11
58: return String.valueOf(this .value);
59: }
60:
61: public String toString() {
62:
63: return "(long)" + value;} //$NON-NLS-1$
64:
65: public int typeID() {
66: return T_long;
67: }
68: }
|