Class AbstractScriptSession.ScriptSessionQueryScope

All Implemented Interfaces:
LogOutputAppendable, QueryScope, LivenessManager, LivenessNode, LivenessReferent, ReleasableLivenessManager
Enclosing class:
AbstractScriptSession<S extends AbstractScriptSession.Snapshot>

public class AbstractScriptSession.ScriptSessionQueryScope extends LivenessScope implements QueryScope
  • Constructor Details

    • ScriptSessionQueryScope

      public ScriptSessionQueryScope()
  • Method Details

    • scriptSession

      public ScriptSession scriptSession()
      Internal workaround to support python calling pushScope.
    • getParamNames

      public Set<String> getParamNames()
      Description copied from interface: QueryScope
      Get all known scope variable names.
      Specified by:
      getParamNames in interface QueryScope
      Returns:
      A caller-owned mutable collection of scope variable names.
    • hasParamName

      public boolean hasParamName(String name)
      Description copied from interface: QueryScope
      Check if the scope has the given name.
      Specified by:
      hasParamName in interface QueryScope
      Parameters:
      name - param name
      Returns:
      True iff the scope has the given param name
    • createParam

      public <T> QueryScopeParam<T> createParam(String name) throws QueryScope.MissingVariableException
      Description copied from interface: QueryScope
      Get a QueryScopeParam by name.
      Specified by:
      createParam in interface QueryScope
      Parameters:
      name - parameter name
      Returns:
      newly-constructed QueryScopeParam (name + value-snapshot pair).
      Throws:
      QueryScope.MissingVariableException - If any of the named scope variables does not exist.
    • readParamValue

      public <T> T readParamValue(String name) throws QueryScope.MissingVariableException
      Description copied from interface: QueryScope
      Get the value of a given scope parameter by name. Callers may want to unwrap language-specific values using QueryScope.unwrapObject(Object) before using them.
      Specified by:
      readParamValue in interface QueryScope
      Parameters:
      name - parameter name.
      Returns:
      parameter value.
      Throws:
      QueryScope.MissingVariableException - If no such scope parameter exists.
    • readParamValue

      public <T> T readParamValue(String name, T defaultValue)
      Description copied from interface: QueryScope
      Get the value of a given scope parameter by name. Callers may want to unwrap language-specific values using QueryScope.unwrapObject(Object) before using them.
      Specified by:
      readParamValue in interface QueryScope
      Parameters:
      name - parameter name.
      defaultValue - default parameter value.
      Returns:
      parameter value, or the default parameter value, if the value is not present.
    • putParam

      public <T> void putParam(String name, T value)
      Description copied from interface: QueryScope
      Add a parameter to the scope. Objects passed in will have their liveness managed by the scope.
      Specified by:
      putParam in interface QueryScope
      Parameters:
      name - parameter name.
      value - parameter value.
    • toMap

      public Map<String,Object> toMap(@NotNull @NotNull QueryScope.ParamFilter<Object> filter)
      Description copied from interface: QueryScope
      Returns a mutable map with all objects in the scope. Callers may want to unwrap language-specific values using QueryScope.unwrapObject(Object) before using them. This returned map is owned by the caller.
      Specified by:
      toMap in interface QueryScope
      Parameters:
      filter - a predicate to filter the map entries
      Returns:
      a caller-owned mutable map with all known variables and their values.
    • toMap

      public <T> Map<String,T> toMap(@NotNull @NotNull Function<Object,T> valueMapper, @NotNull @NotNull QueryScope.ParamFilter<T> filter)
      Description copied from interface: QueryScope
      Returns a mutable map with all objects in the scope.

      Callers may want to pass in a valueMapper of QueryScope.unwrapObject(Object) which would unwrap values before filtering. The returned map is owned by the caller.

      Specified by:
      toMap in interface QueryScope
      Type Parameters:
      T - the type of the mapped values
      Parameters:
      valueMapper - a function to map the values
      filter - a predicate to filter the map entries
      Returns:
      a caller-owned mutable map with all known variables and their values.
    • unwrapObject

      public Object unwrapObject(@Nullable @Nullable Object object)
      Description copied from interface: QueryScope
      Removes any wrapping that exists on a scope param object so that clients can fetch them. Defaults to returning the object itself.
      Specified by:
      unwrapObject in interface QueryScope
      Parameters:
      object - the scoped object
      Returns:
      an obj which can be consumed by a client