Package ortus.boxlang.runtime.context
Class CatchBoxContext
java.lang.Object
ortus.boxlang.runtime.context.BaseBoxContext
ortus.boxlang.runtime.context.CatchBoxContext
- All Implemented Interfaces:
Serializable,IBoxContext,IBoxAttachable
This context represents the context of a template execution in BoxLang
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface ortus.boxlang.runtime.context.IBoxContext
IBoxContext.ScopeSearchResult -
Field Summary
Fields inherited from class ortus.boxlang.runtime.context.BaseBoxContext
buffers, components, currentImports, parent, queryLoops, templates -
Constructor Summary
ConstructorsConstructorDescriptionCatchBoxContext(IBoxContext parent, Key exceptionKey, Throwable exception) Creates a new execution context with a bounded execution template and parent context -
Method Summary
Modifier and TypeMethodDescriptionCan the current context output to the response stream? Contexts tied to a specific object like a function or class may override this to return false based on their own logic.Clear the bufferfindClosestComponent(Key name) Gets the execution state for the closest component.findClosestComponent(Key name, Predicate<IStruct> predicate) Gets the execution state for the closest component with a predicate to filter.flushBuffer(boolean force) Flush the buffer to the output stream and then clears the local buffersGet the bufferIStruct[]Get the stack of components as an arrayGet 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 --------------------------------------------------------------------------invokeComponent(Key name, IStruct attributes, Component.ComponentBody componentBody) Invoke a component callinvokeFunction(Object function) Invoke a function expression such as (()=>{})() using no args.invokeFunction(Object function, Object[] positionalArguments) Invoke a function expression such as (()=>{})() using positional args.invokeFunction(Object function, Map<Key, Object> namedArguments) Invoke a function expression such as (()=>{})() using named args.invokeFunction(Key name) Invoke a function call such as foo() using no args.invokeFunction(Key name, Object[] positionalArguments) Invoke a function call such as foo() using positional args.invokeFunction(Key name, Map<Key, Object> namedArguments) Invoke a function call such as foo() using named args.Pop a buffer from the stackPop a template from the stackpushBuffer(StringBuffer buffer) Push a buffer onto the stack.pushComponent(IStruct executionState) Push a Component to the stackvoidrethrow()rethrows the closest exceptionTry 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) Try to get the requested key from the unscoped scope Meaning it needs to search scopes in order according to it's context.Most of these methods just delegate to the parent context so the catch context is mostly invisible.writeToBuffer(Object o, boolean force) Write output to this buffer.Methods inherited from class ortus.boxlang.runtime.context.BaseBoxContext
findBaseTemplate, findClosestFunctionName, findClosestTemplate, findFunction, getAttachment, getAttachmentKeys, getConfig, getConfigItem, getConfigItem, getConfigItems, getCurrentImports, getFunctionClass, getFunctionInterface, getFunctionParentContext, getModuleRecord, getModuleSettings, getParent, getParentOfType, getQueryRow, getRuntime, getScopeNearby, getTemplates, getVisibleScopes, hasAttachment, hasParent, hasTemplates, includeTemplate, incrementQueryLoop, injectParentContext, injectTopParentContext, invokeFunction, invokeFunction, navigateConfig, popTemplate, pushTemplate, putAttachment, queryFindNearby, registerQueryLoop, registerUDF, registerUDF, removeAttachment, removeParentContext, scopeFindNearby, setParent, unregisterQueryLoop, unwrapQueryColumnMethods 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
startup
-
Constructor Details
-
CatchBoxContext
Creates a new execution context with a bounded execution template and parent context- Parameters:
parent- The parent contextexceptionKey- The key to use for the exceptionexception- The exception to store
-
-
Method Details
-
getVisibleScopes
-------------------------------------------------------------------------- Getters + Setters --------------------------------------------------------------------------- Specified by:
getVisibleScopesin interfaceIBoxContext- Overrides:
getVisibleScopesin classBaseBoxContext- Returns:
- A struct containing all contextual and lexically visible scopes
-
scopeFindNearby
Try to get the requested key from the unscoped scope Meaning it needs to search scopes in order according to it's context. A nearby 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 use if the key is not foundshallow- true, do not delegate to parent or default scope if not found- 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 use if the key is not found- 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 nearby to an execution context- Specified by:
getScopein interfaceIBoxContext- Overrides:
getScopein classBaseBoxContext- Parameters:
name- The name of the scope to get- Returns:
- The requested scope
-
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
-
getDefaultAssignmentScope
Get the default variable assignment scope for this context- Specified by:
getDefaultAssignmentScopein interfaceIBoxContext- Overrides:
getDefaultAssignmentScopein classBaseBoxContext- Returns:
- The scope reference to use
-
rethrow
public void rethrow()rethrows the closest exception- Specified by:
rethrowin interfaceIBoxContext- Overrides:
rethrowin classBaseBoxContext
-
writeToBuffer
Most of these methods just delegate to the parent context so the catch context is mostly invisible.- Specified by:
writeToBufferin interfaceIBoxContext- Overrides:
writeToBufferin classBaseBoxContext- Parameters:
o- The object to write- Returns:
- This context
-
writeToBuffer
Description copied from class:BaseBoxContextWrite output to this buffer. Any input object will be converted to a string If force is true, write even if the setting component has been used with enableOutputOnly=true- Specified by:
writeToBufferin interfaceIBoxContext- Overrides:
writeToBufferin classBaseBoxContext- Parameters:
o- The object to writeforce- true, write even if output is disabled- Returns:
- This context
-
canOutput
Description copied from class:BaseBoxContextCan the current context output to the response stream? Contexts tied to a specific object like a function or class may override this to return false based on their own logic.- Specified by:
canOutputin interfaceIBoxContext- Overrides:
canOutputin classBaseBoxContext
-
flushBuffer
Description copied from class:BaseBoxContextFlush the buffer to the output stream and then clears the local buffers- Specified by:
flushBufferin interfaceIBoxContext- Overrides:
flushBufferin classBaseBoxContext- Parameters:
force- true, flush even if output is disabled- Returns:
- This context
-
clearBuffer
Description copied from class:BaseBoxContextClear the buffer- Specified by:
clearBufferin interfaceIBoxContext- Overrides:
clearBufferin classBaseBoxContext- Returns:
- This context
-
getBuffer
Description copied from class:BaseBoxContextGet the buffer- Specified by:
getBufferin interfaceIBoxContext- Overrides:
getBufferin classBaseBoxContext- Returns:
- The buffer
-
pushBuffer
Description copied from class:BaseBoxContextPush a buffer onto the stack. This is mostly so components can capture any output generated in their body- Specified by:
pushBufferin interfaceIBoxContext- Overrides:
pushBufferin classBaseBoxContext- Parameters:
buffer- The buffer to push- Returns:
- This context
-
popBuffer
Description copied from class:BaseBoxContextPop a buffer from the stack- Specified by:
popBufferin interfaceIBoxContext- Overrides:
popBufferin classBaseBoxContext- Returns:
- This context
-
invokeFunction
Description copied from class:BaseBoxContextInvoke a function call such as foo() using positional args. Will check for a registered BIF first, then search known scopes for a UDF.- Specified by:
invokeFunctionin interfaceIBoxContext- Overrides:
invokeFunctionin classBaseBoxContext- Returns:
- Return value of the function call
-
invokeFunction
Description copied from class:BaseBoxContextInvoke a function call such as foo() using named args. Will check for a registered BIF first, then search known scopes for a UDF.- Specified by:
invokeFunctionin interfaceIBoxContext- Overrides:
invokeFunctionin classBaseBoxContext- Returns:
- Return value of the function call
-
invokeFunction
Description copied from class:BaseBoxContextInvoke a function call such as foo() using no args.- Specified by:
invokeFunctionin interfaceIBoxContext- Overrides:
invokeFunctionin classBaseBoxContext- Returns:
- Return value of the function call
-
invokeFunction
Description copied from class:BaseBoxContextInvoke a function expression such as (()=>{})() using positional args. This method will validate the incoming object is a function type.- Specified by:
invokeFunctionin interfaceIBoxContext- Overrides:
invokeFunctionin classBaseBoxContext- Returns:
- Return value of the function call
-
invokeFunction
Description copied from class:BaseBoxContextInvoke a function expression such as (()=>{})() using named args. This method will validate the incoming object is a function type.- Specified by:
invokeFunctionin interfaceIBoxContext- Overrides:
invokeFunctionin classBaseBoxContext- Returns:
- Return value of the function call
-
invokeFunction
Description copied from class:BaseBoxContextInvoke a function expression such as (()=>{})() using no args. This method will validate the incoming object is a function type.- Specified by:
invokeFunctionin interfaceIBoxContext- Overrides:
invokeFunctionin classBaseBoxContext- Returns:
- Return value of the function call
-
invokeComponent
public Component.BodyResult invokeComponent(Key name, IStruct attributes, Component.ComponentBody componentBody) Description copied from class:BaseBoxContextInvoke a component call- Specified by:
invokeComponentin interfaceIBoxContext- Overrides:
invokeComponentin classBaseBoxContext- Parameters:
name- The name of the component to invokeattributes- The attributes to pass to the componentcomponentBody- The body of the component
-
pushComponent
Description copied from class:BaseBoxContextPush a Component to the stack- Specified by:
pushComponentin interfaceIBoxContext- Overrides:
pushComponentin classBaseBoxContext- Parameters:
executionState- The state for this component execution- Returns:
- This context
-
popComponent
Description copied from class:BaseBoxContextPop a template from the stack- Specified by:
popComponentin interfaceIBoxContext- Overrides:
popComponentin classBaseBoxContext- Returns:
- This context
-
getComponents
Description copied from class:BaseBoxContextGet the stack of components as an array- Specified by:
getComponentsin interfaceIBoxContext- Overrides:
getComponentsin classBaseBoxContext- Returns:
- This context
-
findClosestComponent
Description copied from class:BaseBoxContextGets the execution state for the closest component.- Specified by:
findClosestComponentin interfaceIBoxContext- Overrides:
findClosestComponentin classBaseBoxContext- Returns:
- The execution state for the closest component, null if none was found
-
findClosestComponent
Description copied from class:BaseBoxContextGets the execution state for the closest component with a predicate to filter.- Specified by:
findClosestComponentin interfaceIBoxContext- Overrides:
findClosestComponentin classBaseBoxContext- Returns:
- The execution state for the closest component, null if none was found
-