Class AbstractSingleCallFrame

java.lang.Object
org.praxislive.script.AbstractSingleCallFrame
All Implemented Interfaces:
StackFrame

public abstract class AbstractSingleCallFrame extends Object implements StackFrame
An abstract StackFrame for commands that need to make a stack frame that makes a single call and processes its response.

Subclasses should implement createCall(org.praxislive.script.Env, java.util.List) to create the call when required. Subclasses may additionally override processResult(java.util.List) if the need to alter the return values from the call.

  • Constructor Details

    • AbstractSingleCallFrame

      protected AbstractSingleCallFrame(Namespace namespace, List<Value> args)
  • Method Details

    • getState

      public final StackFrame.State getState()
      Description copied from interface: StackFrame
      Get the current state of this StackFrame.
      Specified by:
      getState in interface StackFrame
      Returns:
      current state
    • getNamespace

      public final Namespace getNamespace()
    • process

      public final StackFrame process(Env env)
      Description copied from interface: StackFrame
      Process the StackFrame. After processing, the StackFrame should have made one or more Calls, returned a child StackFrame, or moved out of the Incomplete state.

      Process may be called multiple times if the state is still incomplete after this method returns and a response has been posted.

      Specified by:
      process in interface StackFrame
      Parameters:
      env - processing environment
      Returns:
      child StackFrame or null
    • postResponse

      public final void postResponse(Call response)
      Description copied from interface: StackFrame
      Used by the script executor to post the result of a Call. The StackFrame should validate the match ID of the response call against any pending calls before processing the call state or arguments.

      If the state is still incomplete after a response is posted, StackFrame.process(org.praxislive.script.Env) will be called again.

      Specified by:
      postResponse in interface StackFrame
      Parameters:
      response - response call
    • postResponse

      public final void postResponse(StackFrame.State state, List<Value> args)
      Description copied from interface: StackFrame
      Used by the script executor to post the result of a child StackFrame returned by StackFrame.process(org.praxislive.script.Env).

      If the state is still incomplete after a response is posted, StackFrame.process(org.praxislive.script.Env) will be called again.

      Specified by:
      postResponse in interface StackFrame
      Parameters:
      state - the completion state of the child stack frame
      args - the result of the child stack frame
    • result

      public final List<Value> result()
      Description copied from interface: StackFrame
      Access the result of this StackFrame.
      Specified by:
      result in interface StackFrame
      Returns:
      result
    • createCall

      protected abstract Call createCall(Env env, List<Value> args) throws Exception
      Create the Call. The call must use Env.getAddress() as the from address, and require a response.
      Parameters:
      env - environment for address, time, etc.
      args - command arguments
      Returns:
      call
      Throws:
      Exception - on error
    • processResult

      protected List<Value> processResult(List<Value> result)
      Process the result from the call on a successful response. Unless this method is overridden the result of the stack frame will be the result of the call.
      Parameters:
      result - successful result from call
      Returns:
      processed result