KickJava   Java API By Example, From Geeks To Geeks.

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


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