1 43 44 package org.exolab.jms.selector; 45 46 import javax.jms.Message ; 47 48 49 59 abstract class MathOperator extends BinaryOperator { 60 61 68 protected MathOperator(final String operator, final Expression lhs, 69 final Expression rhs) { 70 super(operator, lhs, rhs); 71 } 72 73 81 public final SObject evaluate(final Message msg) 82 throws TypeMismatchException { 83 84 SNumber result = null; 85 SNumber lhs = TypeCaster.castToNumber(left().evaluate(msg), context()); 86 if (lhs != null) { 87 SNumber rhs = TypeCaster.castToNumber(right().evaluate(msg), 88 context()); 89 if (rhs != null) { 90 result = evaluate(lhs, rhs); 91 } 92 } 93 return result; 94 } 95 96 103 protected abstract SNumber evaluate(final SNumber lhs, final SNumber rhs); 104 105 110 private final String context() { 111 return "operator " + operator(); 112 } 113 114 } | Popular Tags |