Class VariableUtils


  • public final class VariableUtils
    extends Object
    Utility class manipulating test variables.
    Author:
    Christoph Deppisch
    • Method Detail

      • getValueFromScript

        public static String getValueFromScript​(String scriptEngine,
                                                String code)
        Evaluates script code and returns a variable value as result.
        Parameters:
        scriptEngine - the name of the scripting engine.
        code - the script code.
        Returns:
        the variable value as String.
      • cutOffSingleQuotes

        public static String cutOffSingleQuotes​(String variable)
        Cut off single quotes prefix and suffix.
        Parameters:
        variable -
        Returns:
      • cutOffDoubleQuotes

        public static String cutOffDoubleQuotes​(String variable)
        Cut off double quotes prefix and suffix.
        Parameters:
        variable -
        Returns:
      • cutOffVariablesPrefix

        public static String cutOffVariablesPrefix​(String variable)
        Cut off variables prefix
        Parameters:
        variable -
        Returns:
      • cutOffVariablesEscaping

        public static String cutOffVariablesEscaping​(String variable)
        Cut off variables escaping
        Parameters:
        variable -
        Returns:
      • isVariableName

        public static boolean isVariableName​(String expression)
        Checks whether a given expression is a variable name.
        Parameters:
        expression -
        Returns:
        flag true/false
      • replaceVariablesInString

        public static String replaceVariablesInString​(String str,
                                                      TestContext context,
                                                      boolean enableQuoting)
        Replace all variable expression in a string with its respective value. Variable values are enclosed with quotes if enabled.
        Parameters:
        str -
        context -
        enableQuoting -
        Returns: