Package ortus.boxlang.runtime.scripting
Class BoxScriptingContext
java.lang.Object
ortus.boxlang.runtime.scripting.BoxScriptingContext
- All Implemented Interfaces:
ScriptContext
The BoxScriptingContext is an implementation of the JSR-223 ScriptContext
interface that provides a context for executing BoxLang code.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The BoxLang request scope that doesn't exist in the traditional script contextsFields inherited from interface javax.script.ScriptContext
ENGINE_SCOPE, GLOBAL_SCOPE
-
Constructor Summary
ConstructorsConstructorDescriptionBoxScriptingContext
(IBoxContext boxContext) Constructor for the BoxScriptingContext -
Method Summary
Modifier and TypeMethodDescriptiongetAttribute
(String name) Get the attribute for the given scope by testing all scopes in order: engine, request, globalgetAttribute
(String name, int scope) Get the attribute for the given scopeint
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_SCOPEgetBindings
(int scope) Get the bindings for the given scoperemoveAttribute
(String name, int scope) Remove the attribute for the given scopevoid
setAttribute
(String name, Object value, int scope) Set the attribute for the given scopevoid
setBindings
(Bindings bindings, int scope) Set the bindings for the given scopevoid
setErrorWriter
(Writer writer) void
void
-
Field Details
-
REQUEST_SCOPE
public static final int REQUEST_SCOPEThe BoxLang request scope that doesn't exist in the traditional script contexts- See Also:
-
-
Constructor Details
-
BoxScriptingContext
Constructor for the BoxScriptingContext- Parameters:
boxContext
- The BoxContext this context is associated with
-
-
Method Details
-
setBindings
Set the bindings for the given scope- Specified by:
setBindings
in interfaceScriptContext
- Parameters:
bindings
- The bindings to setscope
- The scope to set the bindings for- Throws:
IllegalArgumentException
- If the scope is invalid
-
getBindings
Get the bindings for the given scope- Specified by:
getBindings
in interfaceScriptContext
- Parameters:
scope
- The scope to get the bindings for- Returns:
- The bindings for the given scope if found, else null
-
setAttribute
Set the attribute for the given scope- Specified by:
setAttribute
in interfaceScriptContext
- Parameters:
name
- The name of the attributevalue
- The value of the attributescope
- The scope to set the attribute for
-
getAttribute
Get the attribute for the given scope- Specified by:
getAttribute
in interfaceScriptContext
- Parameters:
name
- The name of the attributescope
- The scope to get the attribute for- Returns:
- The attribute value if found, else null
-
removeAttribute
Remove the attribute for the given scope- Specified by:
removeAttribute
in interfaceScriptContext
- Parameters:
name
- The name of the attributescope
- The scope to remove the attribute for- Returns:
- The attribute value if found, else null
-
getAttribute
Get the attribute for the given scope by testing all scopes in order: engine, request, global- Specified by:
getAttribute
in interfaceScriptContext
- Parameters:
name
- The name of the attribute- Returns:
- The attribute value if found, else null
-
getAttributesScope
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 interfaceScriptContext
- Parameters:
name
- The name of the attribute- Returns:
- The scope of the attribute if found, else -1
-
getWriter
- Specified by:
getWriter
in interfaceScriptContext
-
getErrorWriter
- Specified by:
getErrorWriter
in interfaceScriptContext
-
setWriter
- Specified by:
setWriter
in interfaceScriptContext
-
setErrorWriter
- Specified by:
setErrorWriter
in interfaceScriptContext
-
getReader
- Specified by:
getReader
in interfaceScriptContext
-
setReader
- Specified by:
setReader
in interfaceScriptContext
-
getScopes
- Specified by:
getScopes
in interfaceScriptContext
-