org.kuali.rice.krad.uif.service
Interface ExpressionEvaluatorService

All Known Implementing Classes:
ExpressionEvaluatorServiceImpl

public interface ExpressionEvaluatorService

Provides evaluation of expression language statements against a given context

Used within the UI framework to allow conditional logic to be configured through the XML which can alter the values of component properties

Author:
Kuali Rice Team (rice.collab@kuali.org)

Field Summary
static String EMBEDDED_PROPERTY_NAME_ADD_INDICATOR
          Indicator that can be added to a property name to indicate the expression result should be added to the property (assumed to be a collection) instead of replaced
 
Method Summary
 boolean containsElPlaceholder(String value)
          Indicates whether or not the given string contains the el placholder (begin and end delimiters)
 Object evaluateExpression(Object contextObject, Map<String,Object> evaluationParameters, String expression)
          Evaluates the given el expression against the content object and parameters, and returns the result of the evaluation
 void evaluateExpressionsOnConfigurable(View view, Configurable configurable, Object contextObject, Map<String,Object> evaluationParameters)
          Evaluates any el expressions that are found as a string property value for the object
 String evaluateExpressionTemplate(Object contextObject, Map<String,Object> evaluationParameters, String expressionTemplate)
          Evaluates the given expression template string against the context object and map of parameters
 String replaceBindingPrefixes(View view, Object object, String expression)
          Adjusts the property expressions for a given object
 

Field Detail

EMBEDDED_PROPERTY_NAME_ADD_INDICATOR

static final String EMBEDDED_PROPERTY_NAME_ADD_INDICATOR
Indicator that can be added to a property name to indicate the expression result should be added to the property (assumed to be a collection) instead of replaced

See Also:
Constant Field Values
Method Detail

evaluateExpressionsOnConfigurable

void evaluateExpressionsOnConfigurable(View view,
                                       Configurable configurable,
                                       Object contextObject,
                                       Map<String,Object> evaluationParameters)
Evaluates any el expressions that are found as a string property value for the object

Using reflection the properties for the object are retrieved and if of String type the corresponding value is retrieved. If the value is not empty and contains the el placeholder see containsElPlaceholder(String) then the expression is evaluated using the given context object and parameters. The evaluated string is then set as the new property value, or in the case of a template (expression contained within a literal string), the expression part is replaced in the property value.

In addition to evaluating any property expressions, any configured PropertyReplacer for the object are also evaluated and if a match occurs those property replacements are made

Parameters:
view - - view instance being rendered
configurable - - object whose properties should be checked for expressions and evaluated
contextObject - - context object for the expression evaluations
evaluationParameters - - map of parameters that may appear in expressions, the map key gives the parameter name that may appear in the expression, and the map value is the object that expression should evaluate against when that name is found

evaluateExpressionTemplate

String evaluateExpressionTemplate(Object contextObject,
                                  Map<String,Object> evaluationParameters,
                                  String expressionTemplate)
Evaluates the given expression template string against the context object and map of parameters

If the template string contains one or more el placeholders (see containsElPlaceholder(String)), the expression contained within the placeholder will be evaluated and the corresponding value will be substituted back into the property value where the placeholder occurred. If no placeholders are found, the string will be returned unchanged

Parameters:
contextObject - - context object for the expression evaluations
evaluationParameters - - map of parameters that may appear in expressions, the map key gives the parameter name that may appear in the expression, and the map value is the object that expression should evaluate against when that name is found
expressionTemplate - - string that should be evaluated for el expressions
Returns:
String formed by replacing any el expressions in the original expression template with their corresponding evaluation results

evaluateExpression

Object evaluateExpression(Object contextObject,
                          Map<String,Object> evaluationParameters,
                          String expression)
Evaluates the given el expression against the content object and parameters, and returns the result of the evaluation

The given expression string is assumed to be one el expression and should not contain the el placeholders. The returned result depends on the evaluation and what type is returns, for instance a boolean will be return for a boolean expression, or a string for string expression

Parameters:
contextObject - - context object for the expression evaluations
evaluationParameters - - map of parameters that may appear in expressions, the map key gives the parameter name that may appear in the expression, and the map value is the object that expression should evaluate against when that name is found
expression - - el expression to evaluate
Returns:
Object result of the expression evaluation

containsElPlaceholder

boolean containsElPlaceholder(String value)
Indicates whether or not the given string contains the el placholder (begin and end delimiters)

Parameters:
value - - String to check for contained placeholders
Returns:
boolean true if the string contains one or more placeholders, false if it contains none
See Also:
org.kuali.rice.krad.uif.UifConstants.EL_PLACEHOLDER_PREFIX, org.kuali.rice.krad.uif.UifConstants.EL_PLACEHOLDER_SUFFIX

replaceBindingPrefixes

String replaceBindingPrefixes(View view,
                              Object object,
                              String expression)
Adjusts the property expressions for a given object

The UifConstants.NO_BIND_ADJUST_PREFIX prefix will be removed as this is a placeholder indicating that the property is directly on the form. The UifConstants.FIELD_PATH_BIND_ADJUST_PREFIX prefix will be replaced by the object's field path - this is only applicable to DataFields. The UifConstants.DEFAULT_PATH_BIND_ADJUST_PREFIX prefix will be replaced by the view's default path if it is set.

Parameters:
view - - the parent view of the object
object - - Object to adjust property expressions on
expression - - The expression to adjust
Returns:
the adjusted expression String


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.