Class UelUtil


  • public final class UelUtil
    extends java.lang.Object
    Implements the Unified Expression Language (JSR-245).
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      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 getLocalizedMapLocaleKey()  
      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,​? extends 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
    • Method Detail

      • getLocalizedMapLocaleKey

        public static java.lang.String getLocalizedMapLocaleKey()
      • 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
      • 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
      • 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
      • 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
      • 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
        See Also:
        StringUtil.convertOperatorSubstitutions(java.lang.String)
      • resolveVariable

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