Class regexMatchFunction
java.lang.Object
org.apache.activemq.filter.function.regexMatchFunction
- All Implemented Interfaces:
FilterFunction
Filter function that matches a value against a regular expression.
REGEX( 'A.B', 'A-B' )
Note that the regular expression is not anchored; use the anchor characters, ^ and $, as-needed. For example, REGEX( 'AA', 'XAAX' ) evaluates to true while REGEX( '^AA$' , 'XAAX' ) evaluates to false.-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionevaluate
(FunctionCallExpression expr, MessageEvaluationContext message) Evalutate the given expression, which consists of a call to this function, in the context given.protected Pattern
getCompiledPattern
(String reg_ex_str) Retrieve a compiled pattern for the given pattern string.boolean
Check whether the given expression is a valid call of this function.boolean
Indicate that this Filter Function evaluates to a Boolean result.
-
Field Details
-
compiledExprCache
-
-
Constructor Details
-
regexMatchFunction
public regexMatchFunction()
-
-
Method Details
-
isValid
Check whether the given expression is a valid call of this function. Two arguments are required. When evaluated, the arguments are converted to strings if they are not already strings.- Specified by:
isValid
in interfaceFilterFunction
- Parameters:
expr
- - the expression consisting of a call to this function.- Returns:
- true - if the expression is valid; false - otherwise.
-
returnsBoolean
Indicate that this Filter Function evaluates to a Boolean result.- Specified by:
returnsBoolean
in interfaceFilterFunction
- Parameters:
expr
- - the expression consisting of a call to this function.- Returns:
- true - this function always evaluates to a Boolean result.
-
evaluate
public Object evaluate(FunctionCallExpression expr, MessageEvaluationContext message) throws jakarta.jms.JMSException Evalutate the given expression, which consists of a call to this function, in the context given. Returns an indication of whether the second argument matches the regular expression in the first argument.- Specified by:
evaluate
in interfaceFilterFunction
- Parameters:
expr
- - the expression consisting of a call to this function.message
- - the context in which the call is being evaluated.- Returns:
- true - if the value matches the regular expression; false - otherwise.
- Throws:
jakarta.jms.JMSException
-
getCompiledPattern
Retrieve a compiled pattern for the given pattern string. A cache of recently used strings is maintained to improve performance.- Parameters:
reg_ex_str
- - the string specifying the regular expression.- Returns:
- Pattern - compiled form of the regular expression.
-