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 30 public final class UnOpSort extends UnaryAlgebra 31 { 32 private static final String RCSRevision = "$Revision: 1.5 $"; 33 private static final String RCSName = "$Name: $"; 34 35 36 private List _sortSpecificationList; 37 38 public UnOpSort() {} 39 40 public UnOpSort(Expression operand, List sortSpecificationList) 41 { 42 super ( operand ) ; 43 setSortSpecificationList( sortSpecificationList) ; 44 } 45 46 synchronized Object clone(Map clonedExprs) throws CloneNotSupportedException 47 { 48 UnOpSort retVal = (UnOpSort)super.clone(clonedExprs); 49 retVal.setSortSpecificationList(AlgebraTools.clone(_sortSpecificationList, clonedExprs)); 50 51 clonedExprs.put(this, retVal); 52 return retVal; 53 } 54 55 60 public List getSortSpecificationList() 61 { 62 return _sortSpecificationList ; 63 } 64 65 public List getParameterList() 66 { 67 return getSortSpecificationList(); 68 } 69 70 76 public void setSortSpecificationList(List sortSpecificationList) { 77 _sortSpecificationList = sortSpecificationList; 78 if (null != _sortSpecificationList) { 79 Iterator itr; 80 itr = _sortSpecificationList.iterator(); 81 while (itr.hasNext()) { 82 ((Expression) itr.next()).setFather(this); 83 } 84 } 85 } 86 87 public void appendSortSpecification (SortSpecification sortSpec) 88 { 89 if (null != sortSpec) { 90 if (null == _sortSpecificationList) { 91 _sortSpecificationList = new ArrayList(); 92 } 93 _sortSpecificationList.add(sortSpec); 94 sortSpec.setFather(this); 95 } 96 } 97 98 public void insertSortSpecification (SortSpecification sortSpec) 99 { 100 if (null != sortSpec) { 101 if (null == _sortSpecificationList) { 102 _sortSpecificationList = new ArrayList(); 103 } 104 _sortSpecificationList.add(0,sortSpec); 105 sortSpec.setFather(this); 106 } 107 } 108 109 public boolean replaceChild(Expression oldChild, Expression newChild) 110 { 111 boolean retVal = false; 112 113 List list = getSortSpecificationList(); 114 115 Expression expr = null ; 116 for (int i = 0; i < list.size(); i++) { 117 expr = (Expression)list.get(i); 118 if (expr.equals(oldChild)) { 119 list.set(i, newChild); 120 newChild.setFather(this); 121 retVal = true; 122 break; 123 } 124 } 125 126 if (getOperand().equals(oldChild)) { 127 setOperand(newChild); 128 retVal = true; 129 } 130 131 return retVal; 132 } 133 134 public List getKeys() { 135 return ((Relation)getOperand()).getKeys(); 136 } 137 138 public SqlExpression accept (GenSqlVisitor visitor) throws SqlWrapperException 139 { 140 return visitor.visit(this); 141 } 142 143 public void accept (AlgebraVisitor visitor) throws SqlWrapperException 144 { 145 visitor.visit(this); 146 } 147 148 151 public boolean deepEquals(Object o) 152 { 153 if (o instanceof UnOpSort) 154 { 155 UnOpSort cast = (UnOpSort)o; 156 boolean ret = super.deepEquals(o) 157 && AlgebraTools.areExprListEquivalent(_sortSpecificationList, cast.getSortSpecificationList()); 158 } 159 return false; 160 } 161 } 162 | Popular Tags |