Class CatchBoxContext

All Implemented Interfaces:
Serializable, IBoxContext, IBoxAttachable

public class CatchBoxContext extends ParentPassthroughBoxContext
This context represents the context of a template execution in BoxLang
See Also:
  • Constructor Details

    • CatchBoxContext

      public CatchBoxContext(IBoxContext parent, Key exceptionKey, Throwable exception)
      Creates a new execution context with a bounded execution template and parent context
      Parameters:
      parent - The parent context
      exceptionKey - The key to use for the exception
      exception - The exception to store
  • Method Details

    • getVisibleScopes

      public IStruct getVisibleScopes(IStruct scopes, boolean nearby, boolean shallow)
      -------------------------------------------------------------------------- Getters + Setters --------------------------------------------------------------------------
      Specified by:
      getVisibleScopes in interface IBoxContext
      Overrides:
      getVisibleScopes in class ParentPassthroughBoxContext
      Returns:
      A struct containing all contextual and lexically visible scopes
    • isKeyVisibleScope

      public boolean isKeyVisibleScope(Key key, boolean nearby, boolean shallow)
      Check if a key is visible in the current context as a scope name. This allows us to "reserve" known scope names to ensure arguments.foo will always look in the proper arguments scope and never in local.arguments.foo for example
      Specified by:
      isKeyVisibleScope in interface IBoxContext
      Overrides:
      isKeyVisibleScope in class ParentPassthroughBoxContext
      Parameters:
      key - The key to check for visibility
      nearby - true, check only scopes that are nearby to the current execution context
      shallow - true, do not delegate to parent or default scope if not found
      Returns:
      True if the key is visible in the current context, else false
    • scopeFindNearby

      public IBoxContext.ScopeSearchResult scopeFindNearby(Key key, IScope defaultScope, boolean shallow, boolean forAssign)
      Try to get the requested key from the unscoped scope Meaning it needs to search scopes in order according to it's context. A nearby lookup is used for the closest context to the executing code
      Specified by:
      scopeFindNearby in interface IBoxContext
      Overrides:
      scopeFindNearby in class ParentPassthroughBoxContext
      Parameters:
      key - The key to search for
      defaultScope - The default scope to use if the key is not found
      shallow - true, do not delegate to parent or default scope if not found
      forAssign - true, this is for an assignment operation
      Returns:
      The value of the key if found
    • scopeFind

      public IBoxContext.ScopeSearchResult scopeFind(Key key, IScope defaultScope, boolean forAssign)
      Try to get the requested key from the unscoped scope Meaning it needs to search scopes in order according to it's context. Unlike scopeFindNearby(), this version only searches trancedent scopes like cgi or server which are never encapsulated like variables is inside a class.
      Specified by:
      scopeFind in interface IBoxContext
      Overrides:
      scopeFind in class ParentPassthroughBoxContext
      Parameters:
      key - The key to search for
      defaultScope - The default scope to use if the key is not found
      forAssign - true, this is for an assignment operation
      Returns:
      The value of the key if found
    • getScope

      public IScope getScope(Key name)
      Get a scope from the context. If not found, the parent context is asked. Don't search for scopes which are nearby to an execution context
      Specified by:
      getScope in interface IBoxContext
      Overrides:
      getScope in class ParentPassthroughBoxContext
      Parameters:
      name - The name of the scope to get
      Returns:
      The requested scope
    • getScopeNearby

      public IScope getScopeNearby(Key name, boolean shallow)
      Get a scope from the context. If not found, the parent context is asked. Search all konwn scopes
      Specified by:
      getScopeNearby in interface IBoxContext
      Overrides:
      getScopeNearby in class ParentPassthroughBoxContext
      Parameters:
      name - The name of the scope to get
      shallow - true, do not delegate to parent or default scope if not found
      Returns:
      The requested scope
    • rethrow

      public void rethrow()
      rethrows the closest exception
      Specified by:
      rethrow in interface IBoxContext
      Overrides:
      rethrow in class BaseBoxContext