Package ortus.boxlang.runtime.scopes
Class BaseScope
java.lang.Object
ortus.boxlang.runtime.types.Struct
ortus.boxlang.runtime.scopes.BaseScope
- All Implemented Interfaces:
Serializable,Map<Key,,Object> IReferenceable,IScope,IStruct,IType,IListenable<IStruct>
- Direct Known Subclasses:
ApplicationScope,ArgumentsScope,AttributesScope,LocalScope,RequestScope,ScopeWrapper,ServerScope,SessionScope,StaticScope,ThisScope,ThreadScope,VariablesScope
Base scope implementation. Extends HashMap for now. May want to switch to composition over inheritance, but this
is simpler for now and using the Key class provides our case insensitivity automatically.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface ortus.boxlang.runtime.types.IStruct
IStruct.TYPES -
Field Summary
FieldsFields inherited from class ortus.boxlang.runtime.types.Struct
EMPTY, INITIAL_CAPACITY, KEY_LENGTH_LONGEST_FIRST_COMPARATOR, wrappedFields inherited from interface ortus.boxlang.runtime.types.meta.IListenable
ALL_KEYS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionassignFinal(IBoxContext context, Key name, Object value) Assign a value to a key in this scope, setting it as finaldereference(IBoxContext context, Key key, Boolean safe) Dereference this object by a key and return the value, or throw exceptionBoxMeta<?> Get the BoxMetadata object for this structGets the name of the lock for use in the lock component.getName()Gets the name of the scopeAssign a value to a key in this scopeputIfAbsent(Key key, Object value) Assign a value to a key in this scope if it doesn't existRemove a value from the struct by a Key objectMethods inherited from class ortus.boxlang.runtime.types.Struct
addAll, assign, asString, clear, computeHashCode, containsKey, containsKey, containsKey, containsValue, dereferenceAndInvoke, dereferenceAndInvoke, entrySet, equals, fromMap, fromMap, get, get, getFunctionContextThisClassForInvoke, getFunctionContextThisInterfaceForInvoke, getFunctionContextThisStaticClassForInvoke, getKeys, getKeysAsStrings, getOrDefault, getOrDefault, getRaw, getType, getWrapped, hashCode, isCaseSensitive, isEmpty, isSoftReferenced, keySet, linkedOf, of, put, putAll, putIfAbsent, putInternal, registerChangeListener, registerChangeListener, remove, remove, removeChangeListener, size, sortedOf, sortedOf, toString, toUnmodifiable, unWrapNull, unWrapNullInternal, values, wrapAssignment, wrapNullMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ortus.boxlang.runtime.dynamic.IReferenceable
assign, dereferenceAndInvoke, dereferenceAndInvokeMethods inherited from interface ortus.boxlang.runtime.scopes.IScope
initializeMethods inherited from interface ortus.boxlang.runtime.types.IStruct
addAll, containsKey, containsKey, entrySet, get, getAs, getAsArray, getAsAttempt, getAsBoolean, getAsBoxInterface, getAsClassRunnable, getAsDateTime, getAsDouble, getAsFunction, getAsInteger, getAsKey, getAsLong, getAsNumber, getAsOptional, getAsQuery, getAsStream, getAsString, getAsStruct, getAsXML, getKeys, getKeysAsStrings, getOrDefault, getOrDefault, getRaw, getType, getWrapped, isCaseSensitive, isSoftReferenced, put, putIfAbsent, removeMethods inherited from interface ortus.boxlang.runtime.types.IType
asString, computeHashCodeMethods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, putAll, remove, remove, replace, replace, replaceAll, size, values
-
Field Details
-
$bx
Metadata object
-
-
Constructor Details
-
BaseScope
Constructor- Parameters:
scopeName- The name of the scope
-
BaseScope
Constructor- Parameters:
scopeName- The name of the scopetype- The Struct type of the scope
-
-
Method Details
-
dereference
Dereference this object by a key and return the value, or throw exception- Specified by:
dereferencein interfaceIReferenceable- Overrides:
dereferencein classStruct- Parameters:
context- The context we're executing inside ofkey- The key to dereferencesafe- Whether to throw an exception if the key is not found- Returns:
- The requested object
-
getBoxMeta
Get the BoxMetadata object for this struct- Specified by:
getBoxMetain interfaceIType- Overrides:
getBoxMetain classStruct- Returns:
- The object for this struct
-
getName
Gets the name of the scope -
getLockName
Gets the name of the lock for use in the lock component. Must be unique per scope instance.- Specified by:
getLockNamein interfaceIScope- Returns:
- The unique lock name for the scope
-
assignFinal
Assign a value to a key in this scope, setting it as final- Specified by:
assignFinalin interfaceIScope- Parameters:
context- The context we're executing inside ofname- The name of the scope to getvalue- The value to assign to the scope- Returns:
- The value that was assigned
-
put
Assign a value to a key in this scope -
putIfAbsent
Assign a value to a key in this scope if it doesn't exist- Specified by:
putIfAbsentin interfaceIStruct- Specified by:
putIfAbsentin interfaceMap<Key,Object> - Overrides:
putIfAbsentin classStruct- Parameters:
key- The key to setvalue- The value to set- Returns:
- The previous value of the key, or null if not found
-
remove
Remove a value from the struct by a Key object
-