Class replaceFunction

java.lang.Object
org.apache.activemq.filter.function.replaceFunction
All Implemented Interfaces:
FilterFunction

public class replaceFunction extends Object implements FilterFunction
Function which replaces regular expression matches in a source string to a replacement literal.

For Example: REPLACE('1,2/3', '[,/]', ';') returns '1;2;3'

  • Constructor Details

    • replaceFunction

      public replaceFunction()
  • Method Details

    • isValid

      public boolean isValid(FunctionCallExpression expr)
      Check whether the given expression is valid for this function.
      Specified by:
      isValid in interface FilterFunction
      Parameters:
      expr - - the expression consisting of a call to this function.
      Returns:
      true - if three arguments are passed to the function; false - otherwise.
    • returnsBoolean

      public boolean returnsBoolean(FunctionCallExpression expr)
      Indicate that this function does not return a boolean value.
      Specified by:
      returnsBoolean in interface FilterFunction
      Parameters:
      expr - - the expression consisting of a call to this function.
      Returns:
      false - this filter function always evaluates to a string.
    • evaluate

      public Object evaluate(FunctionCallExpression expr, MessageEvaluationContext message_ctx) throws jakarta.jms.JMSException
      Evaluate the given expression for this function in the given context. The result of the evaluation is a string with all matches of the regular expression, from the evaluation of the second argument, replaced by the string result from the evaluation of the third argument. Replacement is performed by String#replaceAll().

      Note that all three arguments must be Strings.

      Specified by:
      evaluate in interface FilterFunction
      Parameters:
      expr - - the expression consisting of a call to this function.
      message_ctx - - the context within which to evaluate the call.
      Returns:
      String - the result of the replacement.
      Throws:
      jakarta.jms.JMSException