KickJava   Java API By Example, From Geeks To Geeks.

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


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