01: /**
02: *
03: * Copyright 2004 Protique Ltd
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: **/package org.activemq.filter.mockrunner;
18:
19: import javax.jms.JMSException;
20: import javax.jms.Message;
21:
22: /**
23: * Alwin Ibba: Changed package
24: *
25: * Represents a filter using an expression
26: *
27: * @version $Revision: 1.3 $
28: */
29: public class ExpressionFilter implements Filter {
30:
31: private Expression expression;
32:
33: public ExpressionFilter(Expression expression) {
34: this .expression = expression;
35: }
36:
37: public boolean matches(Message message) throws JMSException {
38: Object value = expression.evaluate(message);
39: if (value != null && value instanceof Boolean) {
40: return ((Boolean) value).booleanValue();
41: }
42: return false;
43: }
44:
45: public boolean isWildcard() {
46: return false;
47: }
48:
49: /**
50: * @return Returns the expression.
51: */
52: public Expression getExpression() {
53: return expression;
54: }
55:
56: /* (non-Javadoc)
57: * @see java.lang.Object#toString()
58: */
59: public String toString() {
60: return "Filter: " + expression;
61: }
62: }
|