Package org.apache.activemq.filter
Class FunctionCallExpression
java.lang.Object
org.apache.activemq.filter.FunctionCallExpression
- All Implemented Interfaces:
Expression
- Direct Known Subclasses:
BooleanFunctionCallExpr
Function call expression for use in selector expressions. Includes an extensible interface to allow custom
functions to be added without changes to the core.
Use registerFunction() to register new function implementations for use in selectors.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Maintain a single function registration.static class
Exception indicating that an invalid function call expression was created, usually by the selector parser. -
Field Summary
Modifier and TypeFieldDescriptionprotected ArrayList
protected FilterFunction
protected String
protected static final HashMap<String,
FunctionCallExpression.functionRegistration> -
Constructor Summary
ModifierConstructorDescriptionprotected
FunctionCallExpression
(String func_name, List<Expression> args) Constructs a function call expression with the named function and argument list. -
Method Summary
Modifier and TypeMethodDescriptionstatic FunctionCallExpression
createFunctionCall
(String func_name, List<Expression> args) Create a function call expression for the named function and argument list, returning a Boolean function call expression if the function returns a boolean value so that it may be used in boolean contexts.static void
deregisterFunction
(String name) Remove the registration of the function with the specified name.evaluate
(MessageEvaluationContext message_ctx) Evaluate the function call expression in the context given.getArgument
(int which) Retrieve the argument at the specified index; the first argument is index 0.int
Retrieve the number of arguments for the function call defined in this expression.static boolean
registerFunction
(String name, FilterFunction impl) Register the function with the specified name.toString()
Translate the expression back into text in a form similar to the input to the selector parser.
-
Field Details
-
functionRegistry
-
functionName
-
arguments
-
filterFunc
-
-
Constructor Details
-
FunctionCallExpression
protected FunctionCallExpression(String func_name, List<Expression> args) throws FunctionCallExpression.invalidFunctionExpressionException Constructs a function call expression with the named function and argument list. Use createFunctionCall() to create instances.- Throws:
FunctionCallExpression.invalidFunctionExpressionException
- - if the function name is not valid.
-
-
Method Details
-
registerFunction
Register the function with the specified name.- Parameters:
name
- - the function name, as used in selector expressions. Case Sensitive.impl
- - class which implements the function interface, including parse-time and evaluation-time operations.- Returns:
- true - if the function is successfully registered; false - if a function with the same name is already registered.
-
deregisterFunction
Remove the registration of the function with the specified name. Note that parsed expressions using this function will still access its implementation after this call.- Parameters:
name
- - name of the function to remove.
-
createFunctionCall
public static FunctionCallExpression createFunctionCall(String func_name, List<Expression> args) throws FunctionCallExpression.invalidFunctionExpressionException Create a function call expression for the named function and argument list, returning a Boolean function call expression if the function returns a boolean value so that it may be used in boolean contexts. Used by the parser when a function call is identified. Note that the function call is created after all argument expressions so that the function call can properly detect whether it evaluates to a Boolean value.- Parameters:
func_name
- - name of the function, as used in selectors.args
- - list of argument expressions passed to the function.- Returns:
- an instance of a BooleanFunctionCallExpr if the function returns a boolean value in this call, or a FunctionCallExpression otherwise.
- Throws:
invalidFunctionExpression
- - if the function name is not valid, or the given argument list is not valid for the function.FunctionCallExpression.invalidFunctionExpressionException
-
getNumArguments
public int getNumArguments()Retrieve the number of arguments for the function call defined in this expression.- Returns:
- the number of arguments being passed to the function.
-
getArgument
Retrieve the argument at the specified index; the first argument is index 0. Used by implementations of FilterFunction objects to check arguments and evaluate them, as needed.- Parameters:
which
- - number of the argument to retrieve; the first is 0.
-
evaluate
Evaluate the function call expression in the context given.- Specified by:
evaluate
in interfaceExpression
- Returns:
- the value of this expression
- Throws:
jakarta.jms.JMSException
- See Also:
-
toString
Translate the expression back into text in a form similar to the input to the selector parser.
-