org.ofbiz.base.util.string
Class UelUtil

java.lang.Object
  extended by org.ofbiz.base.util.string.UelUtil

public class UelUtil
extends java.lang.Object

Implements the Unified Expression Language (JSR-245).


Nested Class Summary
protected static class UelUtil.BasicContext
           
protected static class UelUtil.BasicValueExpression
           
protected static class UelUtil.BasicVariableMapper
           
protected static class UelUtil.ExtendedCompositeResolver
          Custom CompositeELResolver used to handle variable auto-vivify.
protected static class UelUtil.ExtendedListResolver
          Custom ListELResolver used to handle OFBiz List syntax.
protected static class UelUtil.ExtendedMapResolver
          Custom MapELResolver class used to accommodate LocalizedMap instances.
 
Field Summary
protected static ELResolver defaultResolver
           
protected static ExpressionFactory exprFactory
           
static java.lang.String localizedMapLocaleKey
           
protected static java.lang.String module
           
 
Constructor Summary
UelUtil()
           
 
Method Summary
static java.lang.Object autoVivifyListOrMap(java.lang.Object property)
          Evaluates a property Object and returns a new List or Map.
static java.lang.Object evaluate(java.util.Map<java.lang.String,? extends java.lang.Object> context, java.lang.String expression)
          Evaluates a Unified Expression Language expression and returns the result.
static java.lang.Object evaluate(java.util.Map<java.lang.String,? extends java.lang.Object> context, java.lang.String expression, java.lang.Class expectedType)
          Evaluates a Unified Expression Language expression and returns the result.
static java.lang.String prepareExpression(java.lang.String expression)
          Prepares an expression for evaluation by UEL.
static void removeValue(java.util.Map<java.lang.String,java.lang.Object> context, java.lang.String expression)
          Evaluates a Unified Expression Language expression and sets the resulting object to null.
static java.lang.Object resolveVariable(java.lang.String variable, java.util.Map<java.lang.String,java.lang.Object> variables, java.util.Locale locale)
           
static void setValue(java.util.Map<java.lang.String,java.lang.Object> context, java.lang.String expression, java.lang.Class expectedType, java.lang.Object value)
          Evaluates a Unified Expression Language expression and sets the resulting object to the specified value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

module

protected static final java.lang.String module

localizedMapLocaleKey

public static final java.lang.String localizedMapLocaleKey

exprFactory

protected static final ExpressionFactory exprFactory

defaultResolver

protected static final ELResolver defaultResolver
Constructor Detail

UelUtil

public UelUtil()
Method Detail

evaluate

public static java.lang.Object evaluate(java.util.Map<java.lang.String,? extends java.lang.Object> context,
                                        java.lang.String expression)
Evaluates a Unified Expression Language expression and returns the result.

Parameters:
context - Evaluation context (variables)
expression - UEL expression
Returns:
Result object
Throws:
javax.el.* - exceptions

evaluate

public static java.lang.Object evaluate(java.util.Map<java.lang.String,? extends java.lang.Object> context,
                                        java.lang.String expression,
                                        java.lang.Class expectedType)
Evaluates a Unified Expression Language expression and returns the result.

Parameters:
context - Evaluation context (variables)
expression - UEL expression
expectedType - The expected object Class to return
Returns:
Result object
Throws:
javax.el.* - exceptions

setValue

public static void setValue(java.util.Map<java.lang.String,java.lang.Object> context,
                            java.lang.String expression,
                            java.lang.Class expectedType,
                            java.lang.Object value)
Evaluates a Unified Expression Language expression and sets the resulting object to the specified value.

Parameters:
context - Evaluation context (variables)
expression - UEL expression
expectedType - The expected object Class to set
Throws:
javax.el.* - exceptions

removeValue

public static void removeValue(java.util.Map<java.lang.String,java.lang.Object> context,
                               java.lang.String expression)
Evaluates a Unified Expression Language expression and sets the resulting object to null.

Parameters:
context - Evaluation context (variables)
expression - UEL expression
Throws:
javax.el.* - exceptions

autoVivifyListOrMap

public static java.lang.Object autoVivifyListOrMap(java.lang.Object property)
Evaluates a property Object and returns a new List or Map. If property is not a String object type and it evaluates to an integer value, a new List instance is returned, otherwise a new Map instance is returned.

Parameters:
property - Property Object to be evaluated
Returns:
New List or Map

prepareExpression

public static java.lang.String prepareExpression(java.lang.String expression)
Prepares an expression for evaluation by UEL. The OFBiz syntax is converted to UEL-compatible syntax and the resulting expression is returned.

Parameters:
expression - Expression to be converted
Returns:
Converted expression

resolveVariable

public static java.lang.Object resolveVariable(java.lang.String variable,
                                               java.util.Map<java.lang.String,java.lang.Object> variables,
                                               java.util.Locale locale)