KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.xquark.extractor.algebra;
24
25 import java.util.Map JavaDoc;
26
27 import org.xquark.extractor.common.SqlWrapperException;
28 import org.xquark.extractor.sql.SqlExpression;
29
30 public final class LitInteger extends Literal
31 {
32
33     private static final String JavaDoc RCSRevision = "$Revision: 1.4 $";
34     private static final String JavaDoc RCSName = "$Name: $";
35
36     private Integer JavaDoc _value;
37
38
39     public LitInteger(Integer JavaDoc value)
40     {
41         _value = value ;
42     }
43
44     public LitInteger(int value)
45     {
46         _value = new Integer JavaDoc (value) ;
47     }
48
49 // synchronized Object clone(Map clonedExprs) throws CloneNotSupportedException
50
// {
51
// Trace.enter(this, "clone(Map clonedExprs)");
52
// LitInteger retVal = (LitInteger)super.clone();
53
// retVal.setValue((getValue() == null) ? null : new Integer( getValue().intValue()));
54
// clonedExpr.put(this, retVal);Trace.exit(this, "clone(Map clonedExprs)");return retVal;
55
// return retVal;
56
// }
57

58     synchronized Object JavaDoc clone(Map JavaDoc clonedExprs) throws CloneNotSupportedException JavaDoc
59     {
60         //Trace.enter(this, "clone(Map clonedExprs)");
61

62         LitInteger retVal = (LitInteger)super.clone(clonedExprs);
63         retVal.setValue((getValue() == null) ? null : new Integer JavaDoc( getValue().intValue()));
64
65         clonedExprs.put(this, retVal);
66         //Trace.exit(this, "clone(Map clonedExprs)");
67
return retVal;
68     }
69
70     public Integer JavaDoc getValue()
71     {
72         return _value;
73     }
74
75     public void setValue(Integer JavaDoc aValue)
76     {
77         _value = aValue;
78     }
79
80
81     public String JavaDoc pprint ( )
82     {
83         return _value.toString ( ) ;
84     }
85
86     public SqlExpression accept (GenSqlVisitor visitor) throws SqlWrapperException
87     {
88         return visitor.visit(this);
89     }
90
91     public void accept (AlgebraVisitor visitor) throws SqlWrapperException
92     {
93         visitor.visit(this);
94     }
95
96     /**
97      * @see Expression#deepEquals(Object)
98      */

99     public boolean deepEquals(Object JavaDoc o)
100     {
101         if (o instanceof LitInteger)
102         {
103             LitInteger cast = (LitInteger)o;
104             return _value.equals(cast.getValue());
105         }
106         return false;
107     }
108 }
109
Popular Tags