Package ortus.boxlang.runtime.context
Class ContainerBoxContext
java.lang.Object
ortus.boxlang.runtime.context.BaseBoxContext
ortus.boxlang.runtime.context.ContainerBoxContext
- All Implemented Interfaces:
Serializable,IBoxContext,IBoxAttachable
This context provides a "container" to run some code in where we want to have our own
variables scope, but otherwise want to inherit the rest of the requests' scopes
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface ortus.boxlang.runtime.context.IBoxContext
IBoxContext.ScopeSearchResult -
Field Summary
FieldsFields inherited from class ortus.boxlang.runtime.context.BaseBoxContext
currentImports, nullIsUndefined, parent -
Constructor Summary
ConstructorsConstructorDescriptionContainerBoxContext(IBoxContext parent) Creates a new execution context with a bounded execution template and parent context -
Method Summary
Modifier and TypeMethodDescriptionGet the default variable assignment scope for this contextGet a scope from the context.getScopeNearby(Key name, boolean shallow) Get a scope from the context.getVisibleScopes(IStruct scopes, boolean nearby, boolean shallow) -------------------------------------------------------------------------- Getters + Setters --------------------------------------------------------------------------booleanisKeyVisibleScope(Key key, boolean nearby, boolean shallow) Check if a key is visible in the current context as a scope name.voidregisterUDF(UDF udf, boolean override) Register a UDF with the local context choosing to override.Try to get the requested key from the unscoped scope Meaning it needs to search scopes in order according to it's context.scopeFindNearby(Key key, IScope defaultScope, boolean shallow, boolean forAssign) Try to get the requested key from the unscoped scope Meaning it needs to search scopes in order according to it's context.Methods inherited from class ortus.boxlang.runtime.context.BaseBoxContext
_getAttachable, _getBuffers, _getComponents, _getOutputComponentCount, _getQueryLoops, _getTemplates, canOutput, clearBuffer, clearConfigCache, computeAttachmentIfAbsent, findBaseTemplate, findBIF, findClosestComponent, findClosestComponent, findClosestComponent, findClosestComponent, findClosestFunctionName, findClosestTemplate, findFunction, flushBuffer, getApplicationContext, getAttachment, getAttachmentKeys, getBuffer, getComponents, getConfig, getConfigItem, getConfigItem, getConfigItems, getCurrentImports, getFunctionClass, getFunctionInterface, getFunctionParentContext, getFunctionStaticClass, getLogger, getModuleRecord, getModuleSettings, getParent, getParentOfType, getQueryRow, getQueryRow, getRequestContext, getRequestContextOrFail, getRuntime, getScopeNearby, getTemplates, getVisibleScopes, hasAttachment, hasDependentThreads, hasParent, hasTemplates, includeTemplate, incrementQueryLoop, injectParentContext, injectTopParentContext, invokeComponent, invokeFunction, invokeFunction, invokeFunction, invokeFunction, invokeFunction, invokeFunction, invokeFunction, invokeFunction, isDefined, isInOutputComponent, isKeyVisibleScope, navigateConfig, popBuffer, popComponent, popTemplate, pushBuffer, pushComponent, pushTemplate, pushTemplate, putAttachment, queryFindNearby, registerDependentThread, registerQueryLoop, registerShutdownListener, registerUDF, removeAttachment, removeParentContext, rethrow, scopeFindNearby, setParent, shutdown, unregisterDependentThread, unregisterQueryLoop, unwrapQueryColumn, writeToBuffer, writeToBufferMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ortus.boxlang.runtime.context.IBoxContext
getApplicationCache, getApplicationCache, getApplicationName, includeTemplate, registerUDF, startup
-
Field Details
-
variablesScope
The variables scope
-
-
Constructor Details
-
ContainerBoxContext
Creates a new execution context with a bounded execution template and parent context- Parameters:
parent- The parent context
-
-
Method Details
-
getVisibleScopes
-------------------------------------------------------------------------- Getters + Setters --------------------------------------------------------------------------- Specified by:
getVisibleScopesin interfaceIBoxContext- Overrides:
getVisibleScopesin classBaseBoxContext- Returns:
- A struct containing all contextual and lexically visible scopes
-
isKeyVisibleScope
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:
isKeyVisibleScopein interfaceIBoxContext- Overrides:
isKeyVisibleScopein classBaseBoxContext- Parameters:
key- The key to check for visibilitynearby- true, check only scopes that are nearby to the current execution contextshallow- 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) Try to get the requested key from the unscoped scope Meaning it needs to search scopes in order according to it's context. A local lookup is used for the closest context to the executing code- Specified by:
scopeFindNearbyin interfaceIBoxContext- Overrides:
scopeFindNearbyin classBaseBoxContext- Parameters:
key- The key to search fordefaultScope- The default scope to return if the key is not foundshallow- true, do not delegate to parent or default scope if not foundforAssign- true, this is for an assignment operation- Returns:
- The value of the key if found
-
scopeFind
Try to get the requested key from the unscoped scope Meaning it needs to search scopes in order according to it's context. Unlike scopeFindNearby(), this version only searches trancedent scopes like cgi or server which are never encapsulated like variables is inside a class.- Specified by:
scopeFindin interfaceIBoxContext- Overrides:
scopeFindin classBaseBoxContext- Parameters:
key- The key to search fordefaultScope- The default scope to return if the key is not foundforAssign- true, this is for an assignment operation- Returns:
- The value of the key if found
-
getScope
Get a scope from the context. If not found, the parent context is asked. Don't search for scopes which are local to an execution context- Specified by:
getScopein interfaceIBoxContext- Overrides:
getScopein classBaseBoxContext- Parameters:
name- The name of the scope to get- Returns:
- The requested scope
- Throws:
ScopeNotFoundException- If the scope was not found in any context
-
getScopeNearby
Get a scope from the context. If not found, the parent context is asked. Search all konwn scopes- Specified by:
getScopeNearbyin interfaceIBoxContext- Overrides:
getScopeNearbyin classBaseBoxContext- Parameters:
name- The name of the scope to getshallow- true, do not delegate to parent or default scope if not found- Returns:
- The requested scope
- Throws:
ScopeNotFoundException- If the scope was not found in any context
-
registerUDF
Description copied from class:BaseBoxContextRegister a UDF with the local context choosing to override.- Specified by:
registerUDFin interfaceIBoxContext- Overrides:
registerUDFin classBaseBoxContext- Parameters:
udf- The UDF to registeroverride- true, override any existing UDF with the same name
-
getDefaultAssignmentScope
Get the default variable assignment scope for this context- Specified by:
getDefaultAssignmentScopein interfaceIBoxContext- Overrides:
getDefaultAssignmentScopein classBaseBoxContext- Returns:
- The scope reference to use
-