Class StaticClassBoxContext

java.lang.Object
ortus.boxlang.runtime.context.BaseBoxContext
ortus.boxlang.runtime.context.StaticClassBoxContext
All Implemented Interfaces:
Serializable, IBoxContext, IBoxAttachable

public class StaticClassBoxContext extends BaseBoxContext
This context represents the static constructor of a box class
See Also:
  • Field Details

    • staticScope

      protected IScope staticScope
      The static scope
    • staticBoxClass

      protected DynamicObject staticBoxClass
      The class in which this function is executing, if any
  • Constructor Details

    • StaticClassBoxContext

      public StaticClassBoxContext(IBoxContext parent, DynamicObject staticBoxClass, StaticScope staticScope)
      Creates a new execution context with a bounded function instance and parent context
      Parameters:
      parent - The parent context
      staticBoxClass - Static class instance for a boxlang class
      staticScope - The static scope to use
  • Method Details

    • getVisibleScopes

      public IStruct getVisibleScopes(IStruct scopes, boolean nearby, boolean shallow)
      Description copied from class: BaseBoxContext
      This is mostly for the debugger. It returns all visible scopes from this context.
      Specified by:
      getVisibleScopes in interface IBoxContext
      Overrides:
      getVisibleScopes in class BaseBoxContext
      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 BaseBoxContext
      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)
      Search for a variable in "nearby" scopes
      Specified by:
      scopeFindNearby in interface IBoxContext
      Overrides:
      scopeFindNearby in class BaseBoxContext
      Parameters:
      key - The key to search for
      defaultScope - The default scope to use if the key is not found
      shallow - Whether to search only the "nearby" scopes or all scopes
      forAssign - true, this is for an assignment operation
      Returns:
      The search result
    • scopeFind

      public IBoxContext.ScopeSearchResult scopeFind(Key key, IScope defaultScope, boolean forAssign)
      Search for a variable in scopes
      Specified by:
      scopeFind in interface IBoxContext
      Overrides:
      scopeFind in class BaseBoxContext
      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 search result
    • getScope

      public IScope getScope(Key name) throws ScopeNotFoundException
      Look for a scope by name
      Specified by:
      getScope in interface IBoxContext
      Overrides:
      getScope in class BaseBoxContext
      Parameters:
      name - The name of the scope to look for
      Returns:
      The scope reference to use
      Throws:
      ScopeNotFoundException - If the scope was not found in any context
    • getScopeNearby

      public IScope getScopeNearby(Key name, boolean shallow) throws ScopeNotFoundException
      Look for a "nearby" scope by name
      Specified by:
      getScopeNearby in interface IBoxContext
      Overrides:
      getScopeNearby in class BaseBoxContext
      Parameters:
      name - The name of the scope to look for
      shallow - true, do not delegate to parent or default scope if not found
      Returns:
      The scope reference to use
      Throws:
      ScopeNotFoundException - If the scope was not found in any context
    • getDefaultAssignmentScope

      public IScope getDefaultAssignmentScope()
      Get the default variable assignment scope for this context
      Specified by:
      getDefaultAssignmentScope in interface IBoxContext
      Overrides:
      getDefaultAssignmentScope in class BaseBoxContext
      Returns:
      The scope reference to use
    • getFunctionParentContext

      public IBoxContext getFunctionParentContext()
      Get parent context for a function execution happening in this context
      Specified by:
      getFunctionParentContext in interface IBoxContext
      Overrides:
      getFunctionParentContext in class BaseBoxContext
      Returns:
      The context to use
    • registerUDF

      public void registerUDF(UDF udf, boolean override)
      Description copied from class: BaseBoxContext
      Register a UDF with the local context choosing to override.
      Specified by:
      registerUDF in interface IBoxContext
      Overrides:
      registerUDF in class BaseBoxContext
      Parameters:
      udf - The UDF to register
      override - true, override any existing UDF with the same name
    • flushBuffer

      public IBoxContext flushBuffer(boolean force)
      Flush the buffer to the output stream and then clears the local buffers
      Specified by:
      flushBuffer in interface IBoxContext
      Overrides:
      flushBuffer in class BaseBoxContext
      Parameters:
      force - true, flush even if output is disabled
      Returns:
      This context
    • canOutput

      public Boolean canOutput()
      A helper to look at the "output" annotation, caching the result
      Specified by:
      canOutput in interface IBoxContext
      Overrides:
      canOutput in class BaseBoxContext
      Returns:
      Whether the function can output