1 43 44 package org.exolab.jms.selector; 45 46 import javax.jms.Message ; 47 48 49 59 abstract class LogicalOperator extends BinaryOperator { 60 61 68 protected LogicalOperator(final String operator, final Expression lhs, 69 final Expression rhs) { 70 super(operator, lhs, rhs); 71 } 72 73 83 public SObject evaluate(final Message msg) throws TypeMismatchException { 84 SBool result = null; 85 86 SObject lhs = left().evaluate(msg); 87 if (lhs != null) { 88 SObject rhs = right().evaluate(msg); 89 if (rhs != null) { 90 checkTypes(lhs.type(), rhs.type()); 91 result = evaluate(lhs, rhs); 92 } 93 } 94 return result; 95 } 96 97 104 protected SBool evaluate(final SObject lhs, final SObject rhs) { 105 return null; 106 } 107 108 115 protected void checkTypes(final Type lhs, final Type rhs) 116 throws TypeMismatchException { 117 if (lhs != rhs) { 118 StringBuffer msg = new StringBuffer (); 119 msg.append("expecting a "); 120 msg.append(lhs); 121 msg.append(" expression for operator "); 122 msg.append(operator()); 123 msg.append(", found a "); 124 msg.append(rhs); 125 throw new TypeMismatchException(msg.toString()); 126 } 127 } 128 129 } 131 | Popular Tags |