1 16 19 package org.apache.xpath.operations; 20 21 import org.apache.xpath.Expression; 22 import org.apache.xpath.ExpressionOwner; 23 import org.apache.xpath.XPathContext; 24 import org.apache.xpath.XPathVisitor; 25 import org.apache.xpath.objects.XObject; 26 27 30 public class Operation extends Expression implements ExpressionOwner 31 { 32 33 35 protected Expression m_left; 36 37 39 protected Expression m_right; 40 41 51 public void fixupVariables(java.util.Vector vars, int globalsSize) 52 { 53 m_left.fixupVariables(vars, globalsSize); 54 m_right.fixupVariables(vars, globalsSize); 55 } 56 57 58 64 public boolean canTraverseOutsideSubtree() 65 { 66 67 if (null != m_left && m_left.canTraverseOutsideSubtree()) 68 return true; 69 70 if (null != m_right && m_right.canTraverseOutsideSubtree()) 71 return true; 72 73 return false; 74 } 75 76 83 public void setLeftRight(Expression l, Expression r) 84 { 85 m_left = l; 86 m_right = r; 87 l.exprSetParent(this); 88 r.exprSetParent(this); 89 } 90 91 102 public XObject execute(XPathContext xctxt) 103 throws javax.xml.transform.TransformerException 104 { 105 106 XObject left = m_left.execute(xctxt, true); 107 XObject right = m_right.execute(xctxt, true); 108 109 XObject result = operate(left, right); 110 left.detach(); 111 right.detach(); 112 return result; 113 } 114 115 126 public XObject operate(XObject left, XObject right) 127 throws javax.xml.transform.TransformerException 128 { 129 return null; } 131 132 134 public Expression getLeftOperand(){ 135 return m_left; 136 } 137 138 140 public Expression getRightOperand(){ 141 return m_right; 142 } 143 144 class LeftExprOwner implements ExpressionOwner 145 { 146 149 public Expression getExpression() 150 { 151 return m_left; 152 } 153 154 157 public void setExpression(Expression exp) 158 { 159 exp.exprSetParent(Operation.this); 160 m_left = exp; 161 } 162 } 163 164 167 public void callVisitors(ExpressionOwner owner, XPathVisitor visitor) 168 { 169 if(visitor.visitBinaryOperation(owner, this)) 170 { 171 m_left.callVisitors(new LeftExprOwner(), visitor); 172 m_right.callVisitors(this, visitor); 173 } 174 } 175 176 179 public Expression getExpression() 180 { 181 return m_right; 182 } 183 184 187 public void setExpression(Expression exp) 188 { 189 exp.exprSetParent(this); 190 m_right = exp; 191 } 192 193 196 public boolean deepEquals(Expression expr) 197 { 198 if(!isSameClass(expr)) 199 return false; 200 201 if(!m_left.deepEquals(((Operation)expr).m_left)) 202 return false; 203 204 if(!m_right.deepEquals(((Operation)expr).m_right)) 205 return false; 206 207 return true; 208 } 209 } 210 | Popular Tags |