KickJava   Java API By Example, From Geeks To Geeks.

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


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 LongConstant extends Constant {
14 private static final LongConstant ZERO = new LongConstant(0L);
15
16 private long value;
17
18 public static Constant fromValue(long value) {
19     if (value == 0L) {
20         return ZERO;
21     }
22     return new LongConstant(value);
23 }
24 private LongConstant(long value) {
25     this.value = value;
26 }
27 public byte byteValue() {
28     return (byte) value;
29 }
30 public char charValue() {
31     return (char) value;
32 }
33 public double doubleValue() {
34     return value; // implicit cast to return type
35
}
36 public float floatValue() {
37     return value; // implicit cast to return type
38
}
39 public int intValue() {
40     return (int) value;
41 }
42 public long longValue() {
43     return value;
44 }
45 public short shortValue() {
46     return (short) value;
47 }
48 public String JavaDoc stringValue() {
49     //spec 15.17.11
50
return String.valueOf(this.value);
51 }
52 public String JavaDoc toString(){
53
54     return "(long)" + value ; } //$NON-NLS-1$
55
public int typeID() {
56     return T_long;
57 }
58 }
59
Popular Tags