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