1 61 package org.jaxen.expr; 62 63 import org.jaxen.Context; 64 import org.jaxen.JaxenException; 65 import org.jaxen.function.NumberFunction; 66 67 class DefaultModExpr extends DefaultMultiplicativeExpr 68 { 69 DefaultModExpr( Expr lhs, 70 Expr rhs ) 71 { 72 super( lhs, 73 rhs ); 74 } 75 76 public String getOperator() 77 { 78 return "mod"; 79 } 80 81 public Object evaluate( Context context ) throws JaxenException 82 { 83 Number lhsValue = NumberFunction.evaluate( getLHS().evaluate( context ), 84 context.getNavigator() ); 85 Number rhsValue = NumberFunction.evaluate( getRHS().evaluate( context ), 86 context.getNavigator() ); 87 88 double result = lhsValue.doubleValue() % rhsValue.doubleValue(); 89 return new Double ( result ); 90 } 91 92 public void accept( Visitor visitor ) 93 { 94 visitor.visit( this ); 95 } 96 } 97 | Popular Tags |