org.apache.activemq.filter.function
Class replaceFunction

java.lang.Object
  extended by 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 Summary
replaceFunction()
           
 
Method Summary
 Object evaluate(FunctionCallExpression expr, MessageEvaluationContext message_ctx)
          Evaluate the given expression for this function in the given context.
 boolean isValid(FunctionCallExpression expr)
          Check whether the given expression is valid for this function.
 boolean returnsBoolean(FunctionCallExpression expr)
          Indicate that this function does not return a boolean value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

replaceFunction

public replaceFunction()
Method Detail

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 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.
Returns:
String - the result of the replacement.
Throws:
JMSException


Copyright © 2005–2013 The Apache Software Foundation. All rights reserved.