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