org.mule.api.expression
Interface ExpressionManager

All Known Implementing Classes:
DefaultExpressionManager

public interface ExpressionManager

Provides universal access for evaluating expressions embedded in Mule configurations, such as Xml, Java, scripting and annotations.

Users can register or unregister ExpressionEvaluator through this interface.


Field Summary
static String DEFAULT_EXPRESSION_POSTFIX
           
static String DEFAULT_EXPRESSION_PREFIX
           
 
Method Summary
 void clearEnrichers()
          Clears all registered enrichers from the manager.
 void clearEvaluators()
          Clears all registered evaluators from the manager.
 void enrich(String expression, MuleEvent message, Object object)
           
 void enrich(String expression, MuleMessage message, Object object)
          Deprecated. 
 void enrich(String expression, String enricher, MuleMessage message, Object object)
          Enriches the current message
 Object evaluate(String expression, MuleEvent event)
           
 Object evaluate(String expression, MuleEvent event, boolean failIfNull)
           
 Object evaluate(String expression, MuleMessage message)
          Deprecated. 
 Object evaluate(String expression, MuleMessage message, boolean failIfNull)
          Deprecated. 
 Object evaluate(String expression, String evaluator, MuleMessage message, boolean failIfNull)
          Evaluates the given expression.
 boolean evaluateBoolean(String expression, MuleEvent event)
           
 boolean evaluateBoolean(String expression, MuleEvent event, boolean nullReturnsTrue, boolean nonBooleanReturnsTrue)
           
 boolean evaluateBoolean(String expression, MuleMessage message)
          Deprecated. 
 boolean evaluateBoolean(String expression, MuleMessage message, boolean nullReturnsTrue, boolean nonBooleanReturnsTrue)
          Deprecated. 
 boolean evaluateBoolean(String expression, String evaluator, MuleMessage message)
          Evaluates the given expression resolving the result of the evaluation to a boolean.
 boolean evaluateBoolean(String expression, String evaluator, MuleMessage message, boolean nullReturnsTrue, boolean nonBooleanReturnsTrue)
          Evaluates the given expression resolving the result of the evaluation to a boolean.
 boolean isEnricherRegistered(String name)
          Checks whether an enricher is registered with the manager
 boolean isEvaluatorRegistered(String name)
          Checks whether an evaluator is registered with the manager
 boolean isExpression(String string)
          Determines if the string is an expression.
 boolean isValidExpression(String expression)
          Determines if the expression is valid or not.
 String parse(String expression, MuleEvent event)
           
 String parse(String expression, MuleEvent event, boolean failIfNull)
           
 String parse(String expression, MuleMessage message)
          Deprecated. 
 String parse(String expression, MuleMessage message, boolean failIfNull)
          Deprecated. 
 void registerEnricher(ExpressionEnricher enricher)
           
 void registerEvaluator(ExpressionEvaluator evaluator)
           
 ExpressionEnricher unregisterEnricher(String name)
          Removes the enricher with the given name
 ExpressionEvaluator unregisterEvaluator(String name)
          Removes the evaluator with the given name
 void validateExpression(String expression)
          Determines if the expression is valid or not.
 

Field Detail

DEFAULT_EXPRESSION_PREFIX

static final String DEFAULT_EXPRESSION_PREFIX
See Also:
Constant Field Values

DEFAULT_EXPRESSION_POSTFIX

static final String DEFAULT_EXPRESSION_POSTFIX
See Also:
Constant Field Values
Method Detail

registerEvaluator

void registerEvaluator(ExpressionEvaluator evaluator)

isEvaluatorRegistered

boolean isEvaluatorRegistered(String name)
Checks whether an evaluator is registered with the manager

Parameters:
name - the name of the expression evaluator
Returns:
true if the evaluator is registered with the manager, false otherwise

unregisterEvaluator

ExpressionEvaluator unregisterEvaluator(String name)
Removes the evaluator with the given name

Parameters:
name - the name of the evaluator to remove
Returns:
the evaluator that was removed. This will be null if the evaluator was not registered

registerEnricher

void registerEnricher(ExpressionEnricher enricher)

isEnricherRegistered

boolean isEnricherRegistered(String name)
Checks whether an enricher is registered with the manager

Parameters:
name - the name of the expression enricher
Returns:
true if the enricher is registered with the manager, false otherwise

unregisterEnricher

ExpressionEnricher unregisterEnricher(String name)
Removes the enricher with the given name

Parameters:
name - the name of the enricher to remove
Returns:
the enricher that was removed. This will be null if the enricher was not registered

evaluate

@Deprecated
Object evaluate(String expression,
                           MuleMessage message)
                throws ExpressionRuntimeException
Deprecated. 

Evaluates the given expression. The expression should be a single expression definition with or without enclosing braces. i.e. "context:serviceName" and "#[context:serviceName]" are both valid. For situations where one or more expressions need to be parsed within a single text, the parse(String,org.mule.api.MuleMessage,boolean) method should be used since it will iterate through all expressions in a string.

Parameters:
expression - a single expression i.e. xpath://foo
message - The current message being processed
Returns:
the result of the evaluation
Throws:
ExpressionRuntimeException - if the expression is invalid, or a null is found for the expression and 'failIfNull is set to true.

evaluate

Object evaluate(String expression,
                MuleEvent event)
                throws ExpressionRuntimeException
Throws:
ExpressionRuntimeException

evaluate

@Deprecated
Object evaluate(String expression,
                           MuleMessage message,
                           boolean failIfNull)
                throws ExpressionRuntimeException
Deprecated. 

Evaluates the given expression. The expression should be a single expression definition with or without enclosing braces. i.e. "context:serviceName" and "#[context:serviceName]" are both valid. For situations where one or more expressions need to be parsed within a single text, the parse(String,org.mule.api.MuleMessage,boolean) method should be used since it will iterate through all expressions in a string.

Parameters:
expression - a single expression i.e. xpath://foo
message - The current message being processed
failIfNull - determines if an exception should be thrown if expression could not be evaluated or returns null. @return the result of the evaluation
Returns:
the parsered expression string
Throws:
ExpressionRuntimeException - if the expression is invalid, or a null is found for the expression and 'failIfNull is set to true.

evaluate

Object evaluate(String expression,
                MuleEvent event,
                boolean failIfNull)
                throws ExpressionRuntimeException
Throws:
ExpressionRuntimeException

evaluate

Object evaluate(String expression,
                String evaluator,
                MuleMessage message,
                boolean failIfNull)
                throws ExpressionRuntimeException
Evaluates the given expression. The expression should be a single expression definition with or without enclosing braces. i.e. "context:serviceName" and "#[context:serviceName]" are both valid. For situations where one or more expressions need to be parsed within a single text, the parse(String,org.mule.api.MuleMessage,boolean) method should be used since it will iterate through all expressions in a string.

Parameters:
expression - one or more expressions ebedded in a literal string i.e. "Value is #[xpath://foo] other value is #[header:foo]."
evaluator - the evaluator to use when executing the expression
message - The current message being processed
failIfNull - determines if an exception should be thrown if expression could not be evaluated or returns null. @return the result of the evaluation
Returns:
the parsered expression string
Throws:
ExpressionRuntimeException - if the expression is invalid, or a null is found for the expression and 'failIfNull is set to true.

evaluateBoolean

boolean evaluateBoolean(String expression,
                        String evaluator,
                        MuleMessage message)
                        throws ExpressionRuntimeException
Evaluates the given expression resolving the result of the evaluation to a boolean. The expression should be a single expression definition with or without enclosing braces. i.e. "context:serviceName" and "#[context:serviceName]" are both valid.

Parameters:
expression - a single expression i.e. header:foo=bar
evaluator - the evaluator to use when executing the expression
message - The current message being processed
Throws:
ExpressionRuntimeException

evaluateBoolean

@Deprecated
boolean evaluateBoolean(String expression,
                                   MuleMessage message)
                        throws ExpressionRuntimeException
Deprecated. 

Evaluates the given expression resolving the result of the evaluation to a boolean. The expression should be a single expression definition with or without enclosing braces. i.e. "context:serviceName" and "#[context:serviceName]" are both valid.

Parameters:
expression - a single expression i.e. header:foo=bar
message - The current message being processed
Throws:
ExpressionRuntimeException

evaluateBoolean

boolean evaluateBoolean(String expression,
                        MuleEvent event)
                        throws ExpressionRuntimeException
Throws:
ExpressionRuntimeException

evaluateBoolean

boolean evaluateBoolean(String expression,
                        String evaluator,
                        MuleMessage message,
                        boolean nullReturnsTrue,
                        boolean nonBooleanReturnsTrue)
                        throws ExpressionRuntimeException
Evaluates the given expression resolving the result of the evaluation to a boolean. The expression should be a single expression definition with or without enclosing braces. i.e. "context:serviceName" and "#[context:serviceName]" are both valid.

Parameters:
expression - a single expression i.e. header:foo=bar
evaluator - the evaluator to use when executing the expression
message - The current message being processed
nullReturnsTrue - determines if true should be returned if the result of the evaluation is null
nonBooleanReturnsTrue - determines if true should returned if the result is not null but isn't recognised as a boolean
Throws:
ExpressionRuntimeException

evaluateBoolean

@Deprecated
boolean evaluateBoolean(String expression,
                                   MuleMessage message,
                                   boolean nullReturnsTrue,
                                   boolean nonBooleanReturnsTrue)
                        throws ExpressionRuntimeException
Deprecated. 

Evaluates the given expression resolving the result of the evaluation to a boolean. The expression should be a single expression definition with or without enclosing braces. i.e. "context:serviceName" and "#[context:serviceName]" are both valid.

Parameters:
expression - a single expression i.e. header:foo=bar
message - The current message being processed
nullReturnsTrue - determines if true should be returned if the result of the evaluation is null
nonBooleanReturnsTrue - determines if true should returned if the result is not null but isn't recognised as a boolean
Throws:
ExpressionRuntimeException

evaluateBoolean

boolean evaluateBoolean(String expression,
                        MuleEvent event,
                        boolean nullReturnsTrue,
                        boolean nonBooleanReturnsTrue)
                        throws ExpressionRuntimeException
Throws:
ExpressionRuntimeException

enrich

@Deprecated
void enrich(String expression,
                       MuleMessage message,
                       Object object)
Deprecated. 

Enriches the current message using

Parameters:
expression - a single expression i.e. header://foo that defines how the message shoud be enriched
message - The current message being processed that will be enriched
object - The object that will be used to enrich the message

enrich

void enrich(String expression,
            MuleEvent message,
            Object object)

enrich

void enrich(String expression,
            String enricher,
            MuleMessage message,
            Object object)
Enriches the current message

Parameters:
expression - a single expression i.e. header://foo that defines how the message shoud be enriched
enricher - the enricher to use when executing the expression
message - The current message being processed that will be enriched
object - The object that will be used to enrich the message

parse

@Deprecated
String parse(String expression,
                        MuleMessage message)
             throws ExpressionRuntimeException
Deprecated. 

Evaluates expressions in a given string. This method will iterate through each expression and evaluate it. If a user needs to evaluate a single expression they can use evaluate(String,org.mule.api.MuleMessage,boolean).

Parameters:
expression - one or more expressions ebedded in a literal string i.e. "Value is #[xpath://foo] other value is #[header:foo]."
message - The current message being processed
Returns:
the result of the evaluation
Throws:
ExpressionRuntimeException - if the expression is invalid, or a null is found for the expression and 'failIfNull is set to true.

parse

String parse(String expression,
             MuleEvent event)
             throws ExpressionRuntimeException
Throws:
ExpressionRuntimeException

parse

@Deprecated
String parse(String expression,
                        MuleMessage message,
                        boolean failIfNull)
             throws ExpressionRuntimeException
Deprecated. 

Evaluates expressions in a given string. This method will iterate through each expression and evaluate it. If a user needs to evaluate a single expression they can use evaluate(String,org.mule.api.MuleMessage,boolean).

Parameters:
expression - one or more expressions ebedded in a literal string i.e. "Value is #[xpath://foo] other value is #[header:foo]."
message - The current message being processed
failIfNull - determines if an exception should be thrown if expression could not be evaluated or returns null. @return the result of the evaluation
Returns:
the parsered expression string
Throws:
ExpressionRuntimeException - if the expression is invalid, or a null is found for the expression and 'failIfNull is set to true.

parse

String parse(String expression,
             MuleEvent event,
             boolean failIfNull)
             throws ExpressionRuntimeException
Throws:
ExpressionRuntimeException

clearEvaluators

void clearEvaluators()
Clears all registered evaluators from the manager.


clearEnrichers

void clearEnrichers()
Clears all registered enrichers from the manager.


isValidExpression

boolean isValidExpression(String expression)
Determines if the expression is valid or not. This method will validate a single expression or expressions embedded in a string. The expression must either be a well formed expression evaluator i.e. #[bean:user] or must be a valid expression language expression.

Parameters:
expression - the expression to validate
Returns:
true if the expression evaluator is recognised

validateExpression

void validateExpression(String expression)
                        throws InvalidExpressionException
Determines if the expression is valid or not. This method will validate a single expression or expressions embedded in a string. The expression must either be a well formed expression evaluator i.e. #[bean:user] or must be a valid expression language expression.

Parameters:
expression - the expression to validate
Throws:
InvalidExpressionException - if the expression is invalid, including information about the position and fault
Since:
3.0

isExpression

boolean isExpression(String string)
Determines if the string is an expression. This method will validate that the string contains either the expression prefix (malformed) or a full expression. This isn't full proof but catches most error cases

Parameters:
string - is this string an expression string
Returns:
true if the string contains an expression
Since:
3.0


Copyright © 2003-2012 MuleSoft, Inc.. All Rights Reserved.