Class BoxScriptingContext

java.lang.Object
ortus.boxlang.runtime.scripting.BoxScriptingContext
All Implemented Interfaces:
ScriptContext

public class BoxScriptingContext extends Object implements ScriptContext
The BoxScriptingContext is an implementation of the JSR-223 ScriptContext interface that provides a context for executing BoxLang code.
See Also:
  • Field Details

    • REQUEST_SCOPE

      public static final int REQUEST_SCOPE
      The BoxLang request scope that doesn't exist in the traditional script contexts
      See Also:
  • Constructor Details

    • BoxScriptingContext

      public BoxScriptingContext(IBoxContext boxContext)
      Constructor for the BoxScriptingContext
      Parameters:
      boxContext - The BoxContext this context is associated with
  • Method Details

    • setBindings

      public void setBindings(Bindings bindings, int scope)
      Set the bindings for the given scope
      Specified by:
      setBindings in interface ScriptContext
      Parameters:
      bindings - The bindings to set
      scope - The scope to set the bindings for
      Throws:
      IllegalArgumentException - If the scope is invalid
    • getBindings

      public Bindings getBindings(int scope)
      Get the bindings for the given scope
      Specified by:
      getBindings in interface ScriptContext
      Parameters:
      scope - The scope to get the bindings for
      Returns:
      The bindings for the given scope if found, else null
    • setAttribute

      public void setAttribute(String name, Object value, int scope)
      Set the attribute for the given scope
      Specified by:
      setAttribute in interface ScriptContext
      Parameters:
      name - The name of the attribute
      value - The value of the attribute
      scope - The scope to set the attribute for
    • getAttribute

      public Object getAttribute(String name, int scope)
      Get the attribute for the given scope
      Specified by:
      getAttribute in interface ScriptContext
      Parameters:
      name - The name of the attribute
      scope - The scope to get the attribute for
      Returns:
      The attribute value if found, else null
    • removeAttribute

      public Object removeAttribute(String name, int scope)
      Remove the attribute for the given scope
      Specified by:
      removeAttribute in interface ScriptContext
      Parameters:
      name - The name of the attribute
      scope - The scope to remove the attribute for
      Returns:
      The attribute value if found, else null
    • getAttribute

      public Object getAttribute(String name)
      Get the attribute for the given scope by testing all scopes in order: engine, request, global
      Specified by:
      getAttribute in interface ScriptContext
      Parameters:
      name - The name of the attribute
      Returns:
      The attribute value if found, else null
    • getAttributesScope

      public int getAttributesScope(String name)
      Get the scope of the attribute by testing all scopes in order: engine, request, global If the attribute is not found in any scope, return -1 If the attribute is found in the engine scope, return ENGINE_SCOPE If the attribute is found in the request scope, return REQUEST_SCOPE If the attribute is found in the global scope, return GLOBAL_SCOPE
      Specified by:
      getAttributesScope in interface ScriptContext
      Parameters:
      name - The name of the attribute
      Returns:
      The scope of the attribute if found, else -1
    • getWriter

      public Writer getWriter()
      Specified by:
      getWriter in interface ScriptContext
    • getErrorWriter

      public Writer getErrorWriter()
      Specified by:
      getErrorWriter in interface ScriptContext
    • setWriter

      public void setWriter(Writer writer)
      Specified by:
      setWriter in interface ScriptContext
    • setErrorWriter

      public void setErrorWriter(Writer writer)
      Specified by:
      setErrorWriter in interface ScriptContext
    • getReader

      public Reader getReader()
      Specified by:
      getReader in interface ScriptContext
    • setReader

      public void setReader(Reader reader)
      Specified by:
      setReader in interface ScriptContext
    • getScopes

      public List<Integer> getScopes()
      Specified by:
      getScopes in interface ScriptContext