Class BaseScope

java.lang.Object
ortus.boxlang.runtime.types.Struct
ortus.boxlang.runtime.scopes.BaseScope
All Implemented Interfaces:
Serializable, Map<Key,Object>, IReferenceable, IScope, IStruct, IType, IListenable<IStruct>
Direct Known Subclasses:
ApplicationScope, ArgumentsScope, AttributesScope, LocalScope, RequestScope, ScopeWrapper, ServerScope, SessionScope, StaticScope, ThisScope, ThreadScope, VariablesScope

public class BaseScope extends Struct implements IScope
Base scope implementation. Extends HashMap for now. May want to switch to composition over inheritance, but this is simpler for now and using the Key class provides our case insensitivity automatically.
See Also:
  • Field Details

    • $bx

      public transient BoxMeta<?> $bx
      Metadata object
  • Constructor Details

    • BaseScope

      public BaseScope(Key scopeName)
      Constructor
      Parameters:
      scopeName - The name of the scope
    • BaseScope

      public BaseScope(Key scopeName, IStruct.TYPES type)
      Constructor
      Parameters:
      scopeName - The name of the scope
      type - The Struct type of the scope
  • Method Details

    • dereference

      public Object dereference(IBoxContext context, Key key, Boolean safe)
      Dereference this object by a key and return the value, or throw exception
      Specified by:
      dereference in interface IReferenceable
      Overrides:
      dereference in class Struct
      Parameters:
      context - The context we're executing inside of
      key - The key to dereference
      safe - Whether to throw an exception if the key is not found
      Returns:
      The requested object
    • getBoxMeta

      public BoxMeta<?> getBoxMeta()
      Get the BoxMetadata object for this struct
      Specified by:
      getBoxMeta in interface IType
      Overrides:
      getBoxMeta in class Struct
      Returns:
      The object for this struct
    • getName

      public Key getName()
      Gets the name of the scope
      Specified by:
      getName in interface IScope
      Returns:
      The name of the scope
    • getLockName

      public String getLockName()
      Gets the name of the lock for use in the lock component. Must be unique per scope instance.
      Specified by:
      getLockName in interface IScope
      Returns:
      The unique lock name for the scope
    • assignFinal

      public Object assignFinal(IBoxContext context, Key name, Object value)
      Assign a value to a key in this scope, setting it as final
      Specified by:
      assignFinal in interface IScope
      Parameters:
      context - The context we're executing inside of
      name - The name of the scope to get
      value - The value to assign to the scope
      Returns:
      The value that was assigned
    • put

      public Object put(Key key, Object value)
      Assign a value to a key in this scope
      Specified by:
      put in interface IStruct
      Specified by:
      put in interface Map<Key,Object>
      Overrides:
      put in class Struct
      Parameters:
      key - The key to set
      value - The value to set
      Returns:
      The previous value of the key, or null if not found
    • putIfAbsent

      public Object putIfAbsent(Key key, Object value)
      Assign a value to a key in this scope if it doesn't exist
      Specified by:
      putIfAbsent in interface IStruct
      Specified by:
      putIfAbsent in interface Map<Key,Object>
      Overrides:
      putIfAbsent in class Struct
      Parameters:
      key - The key to set
      value - The value to set
      Returns:
      The previous value of the key, or null if not found
    • remove

      public Object remove(Key key)
      Remove a value from the struct by a Key object
      Specified by:
      remove in interface IStruct
      Overrides:
      remove in class Struct
      Parameters:
      key - The String key to remove