001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.activemq.filter; 018 019import java.util.List; 020 021/** 022 * Function call expression that evaluates to a boolean value. Selector parsing requires BooleanExpression objects for 023 * Boolean expressions, such as operands to AND, and as the final result of a selector. This provides that interface 024 * for function call expressions that resolve to Boolean values. 025 * <p/> 026 * If a function can return different types at evaluation-time, the function implementation needs to decide whether it 027 * supports casting to Boolean at parse-time. 028 * 029 * @see FunctionCallExpression#createFunctionCall 030 */ 031 032public class BooleanFunctionCallExpr extends FunctionCallExpression implements BooleanExpression { 033 /** 034 * Constructs a function call expression with the named filter function and arguments, which returns a boolean 035 * result. 036 * 037 * @param func_name - Name of the filter function to be called when evaluated. 038 * @param args - List of argument expressions passed to the function. 039 */ 040 041 public BooleanFunctionCallExpr(String func_name, List<Expression> args) 042 throws invalidFunctionExpressionException { 043 super(func_name, args); 044 } 045 046 047 /** 048 * Evaluate the function call expression, in the given context, and return an indication of whether the 049 * expression "matches" (i.e. evaluates to true). 050 * 051 * @param message_ctx - message context against which the expression will be evaluated. 052 * @return the boolean evaluation of the function call expression. 053 */ 054 055 public boolean matches(MessageEvaluationContext message_ctx) throws javax.jms.JMSException { 056 Boolean result; 057 058 result = (Boolean) evaluate(message_ctx); 059 060 if (result != null) 061 return result.booleanValue(); 062 063 return false; 064 } 065} 066