1 22 23 package org.xquark.extractor.algebra; 24 25 import java.util.*; 26 27 import org.apache.commons.collections.set.ListOrderedSet; 28 29 public abstract class BinaryOperator extends Expression 30 { 31 32 private static final String RCSRevision = "$Revision: 1.5 $"; 33 private static final String RCSName = "$Name: $"; 34 35 protected Expression _rightOperand; 36 protected Expression _leftOperand; 37 protected Set _visibleTableInstance = null; 38 39 public BinaryOperator() {} 40 41 public BinaryOperator(Expression leftOperand, Expression rightOperand) 42 { 43 setLeftOperand ( leftOperand ) ; 44 setRightOperand ( rightOperand ) ; 45 } 46 47 synchronized Object clone(Map clonedExprs) throws CloneNotSupportedException 48 { 49 BinaryOperator retVal = (BinaryOperator)super.clone(clonedExprs); 50 retVal.setLeftOperand((getLeftOperand() == null) ? null : (Expression)getLeftOperand().clone (clonedExprs)); 51 retVal.setRightOperand((getRightOperand() == null) ? null : (Expression) getRightOperand().clone (clonedExprs)); 52 53 clonedExprs.put(this, retVal); 54 return retVal; 55 56 } 57 58 public Expression getLeftOperand() 59 { 60 return _leftOperand ; 61 } 62 63 public Expression getRightOperand() 64 { 65 return _rightOperand ; 66 } 67 68 public void setLeftOperand(Expression leftOperand) 69 { 70 _leftOperand = leftOperand ; 71 _leftOperand.setFather ( this ) ; 72 } 73 74 public void setRightOperand(Expression rightOperand) 75 { 76 _rightOperand = rightOperand ; 77 _rightOperand.setFather ( this ) ; 78 } 79 80 public List getOperands() 81 { 82 ArrayList retVal = new ArrayList () ; 83 retVal.add( _leftOperand ) ; 84 retVal.add( _rightOperand ); 85 return retVal ; 86 } 87 88 public Set visibleTableInstances() { 89 if (null == _visibleTableInstance) 90 _visibleTableInstance = ListOrderedSet.decorate(new HashSet()); 91 92 _visibleTableInstance.clear(); 93 _visibleTableInstance.addAll( ((Relation)getLeftOperand()).providedTableInstances()); 94 _visibleTableInstance.addAll( ((Relation)getRightOperand()).providedTableInstances()); 95 return _visibleTableInstance; 96 } 97 98 101 public boolean deepEquals(Object o) 102 { 103 if (o instanceof BinaryOperator) 104 { 105 BinaryOperator cast = (BinaryOperator)o; 106 return (_leftOperand.deepEquals(cast.getLeftOperand()) 107 && _rightOperand.deepEquals(cast.getRightOperand())) 108 || 109 (_leftOperand.deepEquals(cast.getRightOperand()) 110 && _rightOperand.deepEquals(cast.getLeftOperand())); 111 } 112 return false; 113 } 114 } 115 | Popular Tags |