1 22 23 package org.xquark.extractor.algebra; 24 25 import java.util.Map ; 26 27 import org.xquark.extractor.common.SqlWrapperException; 28 import org.xquark.extractor.sql.SqlExpression; 29 30 public final class SortSpecification extends Expression { 31 32 private static final String RCSRevision = "$Revision: 1.4 $"; 33 private static final String RCSName = "$Name: $"; 34 35 private Expression _sortExpression; 36 private int _sortDirection; 37 38 43 public SortSpecification(Expression sortExpression, int sortDirection) { 44 setSortExpression(sortExpression); 45 _sortDirection = sortDirection; 46 } 47 48 57 synchronized Object clone(Map clonedExprs) throws CloneNotSupportedException { 58 60 SortSpecification retVal = (SortSpecification) super.clone(clonedExprs); 61 retVal.setSortExpression((getSortExpression() == null) ? null : (Expression) getSortExpression().clone(clonedExprs)); 62 clonedExprs.put(this, retVal); 63 return retVal; 65 } 66 67 72 public Expression getSortExpression() { 73 return _sortExpression; 74 } 75 76 public java.util.List getOperands() { 77 return null; 78 } 79 80 85 public void setSortExpression(Expression aSortExpression) { 86 _sortExpression = aSortExpression; 88 _sortExpression.setFather(this); 89 } 90 91 95 public int getSortDirection() { 96 return _sortDirection; 97 } 98 99 103 public void setSortDirection(int sortDirection) { 104 _sortDirection = sortDirection; 105 } 106 107 public boolean replaceChild(Expression oldChild, Expression newChild) { 108 110 boolean retVal = false; 111 if (getSortExpression() == oldChild) { 112 setSortExpression(newChild); 113 retVal = true; 114 } 115 116 return retVal; 118 } 119 120 public String pprint() { 121 String retVal = null; 122 if (getSortDirection() == ASCENDING_ORDER) { 123 return getSortExpression().pprint() + " ASC"; 124 } else { 125 return getSortExpression().pprint() + " DESC"; 126 } 127 } 128 129 public SqlExpression accept(GenSqlVisitor visitor) throws SqlWrapperException { 130 return visitor.visit(this); 131 } 132 133 public void accept(AlgebraVisitor visitor) throws SqlWrapperException { 134 visitor.visit(this); 135 } 136 137 140 public boolean deepEquals(Object o) { 141 if (o instanceof SortSpecification) { 142 SortSpecification cast = (SortSpecification) o; 143 return _sortDirection == cast.getSortDirection() && _sortExpression.deepEquals(cast.getSortExpression()); 144 } 145 return false; 146 } 147 } 148 | Popular Tags |