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 intThe 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 scopeintgetAttributesScope(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 scopevoidsetAttribute(String name, Object value, int scope) Set the attribute for the given scopevoidsetBindings(Bindings bindings, int scope) Set the bindings for the given scopevoidsetErrorWriter(Writer writer) voidvoid
-
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:
setBindingsin 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:
getBindingsin 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:
setAttributein 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:
getAttributein 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:
removeAttributein 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:
getAttributein 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:
getAttributesScopein interfaceScriptContext- Parameters:
name- The name of the attribute- Returns:
- The scope of the attribute if found, else -1
-
getWriter
- Specified by:
getWriterin interfaceScriptContext
-
getErrorWriter
- Specified by:
getErrorWriterin interfaceScriptContext
-
setWriter
- Specified by:
setWriterin interfaceScriptContext
-
setErrorWriter
- Specified by:
setErrorWriterin interfaceScriptContext
-
getReader
- Specified by:
getReaderin interfaceScriptContext
-
setReader
- Specified by:
setReaderin interfaceScriptContext
-
getScopes
- Specified by:
getScopesin interfaceScriptContext
-