1 43 44 package org.exolab.jms.selector; 45 46 import javax.jms.Message ; 47 48 49 58 class And extends LogicalOperator { 59 60 63 private static final String CONTEXT = "and operator"; 64 65 66 72 public And(final Expression lhs, final Expression rhs) { 73 super("and", lhs, rhs); 74 } 75 76 86 public final SObject evaluate(final Message msg) 87 throws TypeMismatchException { 88 SBool result = null; 89 SBool lhs = TypeCaster.castToBool(left().evaluate(msg), CONTEXT); 90 if (lhs != null) { 91 if (!lhs.value()) { 92 result = SBool.FALSE; 93 } else { 94 SBool rhs = TypeCaster.castToBool(right().evaluate(msg), 95 CONTEXT); 96 result = lhs.and(rhs); 97 } 98 } else { 99 SBool rhs = TypeCaster.castToBool(right().evaluate(msg), CONTEXT); 100 if (rhs != null) { 101 result = rhs.and(lhs); 102 } 103 } 104 return result; 105 } 106 107 } | Popular Tags |