KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > el > parser > AstFloatingPoint


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  *
21  * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
22  */
/* Generated By:JJTree: Do not edit this line. AstFloatingPoint.java */
23
24 package com.sun.el.parser;
25
26 import java.math.BigDecimal JavaDoc;
27
28 import javax.el.ELException;
29
30 import com.sun.el.lang.EvaluationContext;
31
32 /**
33  * @author Jacob Hookom [jacob@hookom.net]
34  * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: kchung $
35  */

36 public final class AstFloatingPoint extends SimpleNode {
37     public AstFloatingPoint(int id) {
38         super(id);
39     }
40
41     private Number JavaDoc number;
42
43     public Number JavaDoc getFloatingPoint() {
44         if (this.number == null) {
45             try {
46                 this.number = new Double JavaDoc(this.image);
47             } catch (ArithmeticException JavaDoc e0) {
48                 this.number = new BigDecimal JavaDoc(this.image);
49             }
50         }
51         return this.number;
52     }
53
54     public Object JavaDoc getValue(EvaluationContext ctx)
55             throws ELException {
56         return this.getFloatingPoint();
57     }
58
59     public Class JavaDoc getType(EvaluationContext ctx)
60             throws ELException {
61         return this.getFloatingPoint().getClass();
62     }
63 }
64
Popular Tags