Class ArgumentUtil

java.lang.Object
ortus.boxlang.runtime.util.ArgumentUtil

public class ArgumentUtil extends Object
Represents an argument to a function or BIF
  • Constructor Details

    • ArgumentUtil

      public ArgumentUtil()
  • Method Details

    • createArgumentsScope

      public static ArgumentsScope createArgumentsScope(IBoxContext context, Object[] positionalArguments, Argument[] arguments, ArgumentsScope scope, Key functionName)
      Create an arguments scope from the positional arguments
      Parameters:
      context - The context of the execution
      positionalArguments - The positional arguments
      arguments - The declared arguments
      scope - The scope to add the arguments to
      functionName - The name of the function
      Returns:
      The arguments scope
    • createArgumentsScope

      public static ArgumentsScope createArgumentsScope(IBoxContext context, Map<Key,Object> namedArguments, Argument[] arguments, ArgumentsScope scope, Key functionName)
      Create an arguments scope from the named arguments
      Parameters:
      context - The context of the execution
      namedArguments - The named arguments
      arguments - The declared arguments
      scope - The scope to add the arguments to
      functionName - The name of the function
      Returns:
      The arguments scope
    • createArgumentsScope

      public static ArgumentsScope createArgumentsScope(IBoxContext context, Object[] positionalArguments)
      Create a generic arguments scope from the positional arguments
      Parameters:
      context - The context of the execution
      positionalArguments - The positional arguments
      Returns:
      The arguments scope
    • createArgumentsScope

      public static ArgumentsScope createArgumentsScope(IBoxContext context, Map<Key,Object> namedArguments)
      Create a generic arguments scope from the named arguments
      Parameters:
      context - The context of the execution
      namedArguments - The named arguments
      Returns:
      The arguments scope
    • createArgumentsScope

      public static ArgumentsScope createArgumentsScope(IBoxContext context, Argument[] arguments, ArgumentsScope scope, Key functionName)
      Create an arguments scope from no arguments
      Parameters:
      context - The context of the execution
      arguments - The declared arguments
      scope - The scope to add the arguments to
      functionName - The name of the function
      Returns:
      The arguments scope
    • ensureArgumentType

      public static Object ensureArgumentType(IBoxContext context, Key name, Object value, String type, Key functionName)
      Ensure the argument is the correct type
      Parameters:
      context - The context of the execution
      name - The name of the argument
      value - The value of the argument
      type - The type of the argument
      functionName - The name of the function
      Returns:
      The value of the argument
    • positionalToMap

      public static Map<Key,Object> positionalToMap(Object... args)
      Convert positional arguments to a map of key/value pairs
      Parameters:
      args - The positional arguments
      Returns:
      The map of key/value pairs
    • mapArgumentsToDeclaredArguments

      public static Map<Key,Object> mapArgumentsToDeclaredArguments(Map<Key,Object> args, Argument[] declaredArguments)
      Map the arguments to the declared arguments by position
      Parameters:
      args - The arguments to map. Each key is the position of the argument
      declaredArguments - The declared arguments
      Returns:
      The mapped arguments, if any.