1 22 23 package org.xquark.extractor.algebra; 24 25 import java.util.*; 26 27 import org.xquark.extractor.common.Debug; 28 import org.xquark.extractor.common.SqlWrapperException; 29 import org.xquark.extractor.sql.SqlExpression; 30 import org.xquark.xquery.parser.XQueryExpression; 31 32 public abstract class Expression implements Cloneable , Constants 33 { 34 private static final String RCSRevision = "$Revision: 1.6 $"; 35 private static final String RCSName = "$Name: $"; 36 37 protected SqlType _type; 38 protected Expression _father; 39 protected XQueryExpression _OrginalXExpr; 40 protected Set _referredAttributes; 41 protected Mapper _mapper; 42 43 48 public org.xquark.extractor.algebra.Expression getFather() 49 { 50 return _father; 51 } 52 53 59 public void setFather(org.xquark.extractor.algebra.Expression aFather) 60 { 61 _father = aFather; 62 } 63 64 69 public XQueryExpression getOrginalXExpr() 70 { 71 return _OrginalXExpr; 72 } 73 74 80 public void setOrginalXExpr(XQueryExpression aOrginalXExpr) 81 { 82 _OrginalXExpr = aOrginalXExpr; 83 } 84 85 86 public void setType(SqlType type) 87 { 88 _type = type; 89 } 90 91 96 public Set getReferredAttributes() 97 { 98 return _referredAttributes; 99 } 100 101 107 public void setReferredAttributes(Set aReferredAttributes) 108 { 109 _referredAttributes = aReferredAttributes; 110 } 111 112 117 public Mapper getMapper() 118 { 119 120 return _mapper; 121 } 122 123 129 public void setMapper(Mapper aMapper) 130 { 131 _mapper = aMapper; 133 } 134 135 public abstract List getOperands(); 136 137 public SqlType getType() 138 { 139 return _type; 140 } 141 142 public List getChildren() 143 { 144 Debug.nyi("List getChildren()"); 145 return null; 146 } 147 148 public String pprint() 149 { 150 return this.getClass().getName(); 151 } 152 153 public String toString() { 154 return pprint(); 155 } 156 157 public synchronized Object clone() throws CloneNotSupportedException 159 { 160 Object retVal = null; 161 Map clonedExprs = new HashMap(500); 162 retVal = clone(clonedExprs); 163 clonedExprs.clear(); 164 clonedExprs = null; 165 166 return retVal; 167 } 168 169 synchronized Object clone(Map clonedExprs) throws CloneNotSupportedException 170 { 171 return super.clone(); 172 } 173 174 public String getName() 175 { 176 return null; 177 } 178 179 public boolean replaceChild(Expression oldChild, Expression newChild) 180 { 181 Debug.assertTrue(false,"NYI!! for " + this.pprint()); 182 return false; 183 } 184 185 public abstract SqlExpression accept (GenSqlVisitor visitor) throws SqlWrapperException; 186 187 public abstract void accept (AlgebraVisitor visitor) throws SqlWrapperException; 188 189 public Set getReferredTableInstances() 190 { 191 Set retVal = new HashSet(); 192 if (null != _referredAttributes) { 193 Iterator iter = _referredAttributes.iterator(); 194 AttributeExpression item; 195 while (iter.hasNext()) { 196 item = (AttributeExpression)iter.next(); 197 retVal.add(item.getTableInstance()); 198 } 199 } 200 return retVal; 201 } 202 203 208 public abstract boolean deepEquals(Object o); 209 } 210 211 | Popular Tags |