1 61 62 63 64 package org.jaxen.expr; 65 66 import org.jaxen.Context; 67 import org.jaxen.JaxenException; 68 import org.jaxen.Navigator; 69 import org.jaxen.function.BooleanFunction; 70 71 class DefaultOrExpr extends DefaultLogicalExpr 72 { 73 DefaultOrExpr(Expr lhs, 74 Expr rhs) 75 { 76 super( lhs, 77 rhs ); 78 } 79 80 public String getOperator() 81 { 82 return "or"; 83 } 84 85 public String toString() 86 { 87 return "[(DefaultOrExpr): " + getLHS() + ", " + getRHS() + "]"; 88 } 89 90 public Object evaluate(Context context) throws JaxenException 91 { 92 Navigator nav = context.getNavigator(); 93 Boolean lhsValue = BooleanFunction.evaluate( getLHS().evaluate( context ), nav ); 94 95 if ( lhsValue.booleanValue() ) 96 { 97 return Boolean.TRUE; 98 } 99 100 Boolean rhsValue = BooleanFunction.evaluate( getRHS().evaluate( context ), nav ); 103 104 if ( rhsValue.booleanValue() ) 105 { 106 return Boolean.TRUE; 107 } 108 109 return Boolean.FALSE; 110 } 111 112 public void accept(Visitor visitor) 113 { 114 visitor.visit(this); 115 } 116 117 } 118 | Popular Tags |