KickJava   Java API By Example, From Geeks To Geeks.

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


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.List JavaDoc;
26 import java.util.Map JavaDoc;
27
28 import org.xquark.extractor.common.SqlWrapperException;
29 import org.xquark.extractor.sql.SqlExpression;
30
31 public final class UnOpGroup extends UnaryAlgebra
32 {
33
34     private static final String JavaDoc RCSRevision = "$Revision: 1.5 $";
35     private static final String JavaDoc RCSName = "$Name: $";
36
37
38     private List JavaDoc _groupExpressionList;
39
40     public UnOpGroup(Expression operand, List JavaDoc groupExpressionList)
41     {
42         super(operand);
43         setGroupExpressionList ( groupExpressionList ) ;
44     }
45
46     synchronized Object JavaDoc clone(Map JavaDoc clonedExprs) throws CloneNotSupportedException JavaDoc
47     {
48         UnOpGroup retVal = (UnOpGroup)super.clone(clonedExprs);
49         retVal.setGroupExpressionList(AlgebraTools.clone(_groupExpressionList,clonedExprs));
50
51         clonedExprs.put(this, retVal);
52         return retVal;
53     }
54
55     /**
56      * Access method for the _groupExpressionList property.
57      *
58      * @return the current value of the _groupExpressionList property
59      */

60     public List JavaDoc getGroupExpressionList()
61     {
62         return _groupExpressionList ;
63     }
64
65     public List JavaDoc getParameterList()
66     {
67         return getGroupExpressionList();
68     }
69
70     /**
71      * Sets the value of the _groupExpressionList property.
72      *
73      * @param aGroupExpressionList
74      * the new value of the _groupExpressionList property
75      */

76     public void setGroupExpressionList(List JavaDoc aGroupExpressionList)
77     {
78         _groupExpressionList = aGroupExpressionList;
79         if ( null != _groupExpressionList) {
80             Expression expr = null;
81             for (int i = 0; i < _groupExpressionList.size(); i++) {
82                 expr = (Expression)_groupExpressionList.get(i);
83                 expr.setFather(this);
84             }
85         }
86     }
87
88     public List JavaDoc getKeys() {
89         return _groupExpressionList;
90     }
91
92     public boolean replaceChild(Expression oldChild, Expression newChild)
93     {
94         boolean retVal = false;
95
96         List JavaDoc list = getGroupExpressionList();
97
98         Expression expr = null ;
99         for (int i = 0; i < list.size(); i++) {
100             expr = (Expression)list.get(i);
101             if (expr.equals(oldChild)) {
102                 list.set(i, newChild);
103                 newChild.setFather(this);
104                 retVal = true;
105                 break;
106             }
107         }
108
109         if (getOperand().equals(oldChild)) {
110             setOperand(newChild);
111             retVal = true;
112         }
113
114         return retVal;
115     }
116
117     public SqlExpression accept (GenSqlVisitor visitor) throws SqlWrapperException
118     {
119         return visitor.visit(this);
120     }
121
122     public void accept (AlgebraVisitor visitor) throws SqlWrapperException
123     {
124         visitor.visit(this);
125     }
126
127     /**
128      * @see Expression#deepEquals(Object)
129      */

130     public boolean deepEquals(Object JavaDoc o)
131     {
132         if (o instanceof UnOpGroup)
133         {
134             UnOpGroup cast = (UnOpGroup)o;
135             return super.deepEquals(o)
136                 && AlgebraTools.areExprListEquivalent(_groupExpressionList, cast.getGroupExpressionList());
137         }
138         return false;
139     }
140 }
141
Popular Tags