1 22 23 package org.xquark.extractor.algebra; 24 25 import java.util.List ; 26 import java.util.Map ; 27 28 import org.xquark.extractor.common.SqlWrapperException; 29 import org.xquark.extractor.sql.SqlExpression; 30 31 41 public final class IfThenElse extends Expression { 42 43 private static final String RCSRevision = "$Revision: 1.4 $"; 44 private static final String RCSName = "$Name: $"; 45 46 protected Expression _if; 47 protected Expression _then; 48 protected Expression _else; 49 50 public IfThenElse() {} 51 52 public IfThenElse(Expression iif, Expression tthen, Expression eelse) { 53 setIf(iif); 54 setThen(tthen); 55 setElse(eelse); 56 } 57 58 synchronized Object clone(Map clonedExprs) 59 throws CloneNotSupportedException { 60 IfThenElse retVal = (IfThenElse) super.clone(clonedExprs); 62 retVal.setIf( 63 (getIf() == null) ? null : (Expression) getIf().clone(clonedExprs)); 64 retVal.setThen( 65 (getThen() == null) 66 ? null 67 : (Expression) getThen().clone(clonedExprs)); 68 retVal.setElse( 69 (getElse() == null) 70 ? null 71 : (Expression) getElse().clone(clonedExprs)); 72 clonedExprs.put(this, retVal); 73 return retVal; 75 } 76 77 public Expression getIf() { 78 return _if; 79 } 80 81 public void setIf(Expression iif) { 82 _if = iif; 83 } 84 85 public Expression getThen() { 86 return _then; 87 } 88 89 public void setThen(Expression tthen) { 90 _then = tthen; 91 } 92 93 public Expression getElse() { 94 return _else; 95 } 96 97 public void setElse(Expression eelse) { 98 _else = eelse; 99 } 100 101 public List getOperands() { 102 return null; 103 } 104 105 public boolean replaceChild(Expression oldChild, Expression newChild) { 106 boolean retVal = false; 108 109 if (getIf().equals(oldChild)) { 110 setIf(newChild); 111 retVal = true; 112 } 113 else if (getThen().equals(oldChild)) { 114 setThen(newChild); 115 retVal = true; 116 } 117 else if (getElse().equals(oldChild)) { 118 setElse(newChild); 119 retVal = true; 120 } 121 122 return retVal; 124 } 125 126 public SqlExpression accept(GenSqlVisitor visitor) 127 throws SqlWrapperException { 128 return visitor.visit(this); 129 } 130 131 public void accept(AlgebraVisitor visitor) throws SqlWrapperException { 132 visitor.visit(this); 133 } 134 135 140 public boolean deepEquals(Object o) { 141 if (o instanceof IfThenElse) { 142 IfThenElse cast = (IfThenElse) o; 143 return _if.deepEquals(cast.getIf()) 144 && _then.deepEquals(cast.getThen()) 145 && _else.deepEquals(cast.getElse()); 146 } 147 return false; 148 } 149 } 150 | Popular Tags |