1 22 23 package org.xquark.extractor.algebra; 24 25 import java.util.*; 26 27 import org.xquark.extractor.common.SqlWrapperException; 28 import org.xquark.extractor.sql.SqlExpression; 29 import org.xquark.xquery.parser.XQueryExpression; 30 31 32 38 public final class TupleExpression extends Expression { 39 40 private static final String RCSRevision = "$Revision: 1.5 $"; 41 private static final String RCSName = "$Name: $"; 42 43 44 protected List _itemList; 45 protected RenameRelation _tableInstance; 46 47 public TupleExpression() { 48 } 49 50 public TupleExpression(RenameRelation tableInstance , List itemList, XQueryExpression aOrginalXExpr) 51 { 52 setTableInstance(tableInstance); 53 setItemList(itemList); 54 setOrginalXExpr(aOrginalXExpr); 55 } 56 57 58 synchronized Object clone(Map clonedExprs) throws CloneNotSupportedException 59 { 60 TupleExpression retVal = (TupleExpression)super.clone(clonedExprs); 62 retVal.setItemList(AlgebraTools.clone(_itemList, clonedExprs)); 63 clonedExprs.put(this, retVal); 64 return retVal; 66 } 67 68 69 public RenameRelation getTableInstance() 70 { 71 return _tableInstance ; 72 } 73 74 public void setTableInstance(RenameRelation tableInstance) 75 { 76 _tableInstance = tableInstance; 77 } 78 79 84 public List getItemList() 85 { 86 return _itemList ; 87 } 88 89 public List getOperands() { 90 return null; 91 } 92 93 98 public void setItemList(List itemList) 99 { 100 102 _itemList = itemList; 103 104 if (null==_itemList) { 105 return ; 106 } 107 108 Iterator iter = _itemList.iterator(); 109 while (iter.hasNext()) { 110 Expression item = (Expression)iter.next(); 111 item.setFather(this); 112 } 113 114 } 116 117 118 122 public void addItem(AttributeExpression itemExpr) 123 { 124 126 if ( null == _itemList ) 127 { 128 _itemList = new ArrayList (); 129 } 130 131 _itemList.add ( itemExpr ) ; 132 itemExpr.setFather(this); 133 134 } 136 137 138 public void arithmeticOperation(int operater,Expression leftOperand,Expression rightOperand) 139 { 140 142 } 159 160 161 162 163 public void addNameTest (String name) 164 { 165 } 175 176 public List nameTest (String name) 177 { 178 180 List retVal = null; 181 182 200 return retVal; 202 } 203 204 public boolean replaceChild(Expression oldChild, Expression newChild) 205 { 206 boolean retVal = false; 208 209 List list = getItemList(); 210 211 Expression expr = null ; 212 for (int i = 0; i < list.size(); i++) { 213 expr = (Expression)list.get(i); 214 if (expr.equals(oldChild)) { 215 list.set(i, newChild); 216 newChild.setFather(this); 217 retVal = true; 218 break; 219 } 220 } 221 222 return retVal; 224 } 225 226 public SqlExpression accept (GenSqlVisitor visitor) throws SqlWrapperException 227 { 228 return visitor.visit(this); 229 } 230 231 public void accept (AlgebraVisitor visitor) throws SqlWrapperException 232 { 233 visitor.visit(this); 234 } 235 236 239 public boolean deepEquals(Object o) 240 { 241 if (o instanceof TupleExpression) 242 { 243 TupleExpression cast = (TupleExpression)o; 244 return _tableInstance.deepEquals(cast.getTableInstance()) && AlgebraTools.areExprListEquivalent(_itemList, cast.getItemList()); 246 } 247 return false; 248 } 249 } 250 | Popular Tags |