KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > extractor > algebra > LitDecimal


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23
24 package org.xquark.extractor.algebra;
25
26 import java.math.BigDecimal JavaDoc;
27 import java.util.Map JavaDoc;
28
29 import org.xquark.extractor.common.SqlWrapperException;
30 import org.xquark.extractor.sql.SqlExpression;
31
32 public final class LitDecimal extends Literal
33 {
34
35     private static final String JavaDoc RCSRevision = "$Revision: 1.4 $";
36     private static final String JavaDoc RCSName = "$Name: $";
37
38     private BigDecimal JavaDoc _value;
39
40
41     public LitDecimal(BigDecimal JavaDoc value)
42     {
43         _value = value ;
44     }
45
46     synchronized Object JavaDoc clone(Map JavaDoc clonedExprs) throws CloneNotSupportedException JavaDoc
47     {
48         //Trace.enter(this, "clone(Map clonedExprs)");
49

50         LitDecimal retVal = (LitDecimal)super.clone(clonedExprs);
51         retVal.setValue((getValue() == null) ? null : new BigDecimal JavaDoc(getValue().toString()));
52
53         clonedExprs.put(this, retVal);
54         //Trace.exit(this, "clone(Map clonedExprs)");
55
return retVal;
56     }
57
58     public BigDecimal JavaDoc getValue()
59     {
60         return _value;
61     }
62
63     public void setValue(BigDecimal JavaDoc aValue)
64     {
65         _value = aValue;
66     }
67
68
69     public String JavaDoc pprint ( )
70     {
71         return _value.toString ( ) ;
72     }
73
74     public SqlExpression accept (GenSqlVisitor visitor) throws SqlWrapperException
75     {
76         return visitor.visit(this);
77     }
78
79     public void accept (AlgebraVisitor visitor) throws SqlWrapperException
80     {
81         visitor.visit(this);
82     }
83
84     /**
85      * @see Expression
86      */

87     public boolean deepEquals(Object JavaDoc o)
88     {
89         if (o instanceof LitDecimal)
90         {
91             LitDecimal cast = (LitDecimal)o;
92             return _value.equals(cast.getValue());
93         }
94         return false;
95     }
96 }
97
Popular Tags