Class AbstractVariableResolver
java.lang.Object
com.blackrook.rookscript.resolvers.variable.AbstractVariableResolver
- All Implemented Interfaces:
ScriptVariableResolver
- Direct Known Subclasses:
DefaultVariableResolver,ScriptValue.MapType
A single, scoped open variable set in which values can be set.
All variable names are CASE-INSENSITIVE.
The internals are written so that the storage uses few memory allocations/deletions.
None of the variables are read-only. This implementation is thread-safe.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault capacity.protected AbstractVariableResolver.Entry[]List of entries.protected intCount. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractVariableResolver(int capacity) Creates a variable resolver with a default size. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsValue(String name) Checks if this contains a value by its variable name.protected ScriptValueprotected intbooleangetValue(String name, ScriptValue out) Gets the corresponding value for a variable name.booleanisEmpty()Checks if this resolver maintains no values.booleanisReadOnly(String name) Checks if an existing value is read-only.protected voidremoveIndex(int i) voidsetValue(String name, ScriptValue value) Sets a key-value pair.intsize()toString()
-
Field Details
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITYDefault capacity.- See Also:
-
entries
List of entries. -
entryCount
protected int entryCountCount.
-
-
Constructor Details
-
AbstractVariableResolver
protected AbstractVariableResolver(int capacity) Creates a variable resolver with a default size.- Parameters:
capacity- the initial capacity.
-
-
Method Details
-
get
-
getIndex
-
removeIndex
protected void removeIndex(int i) -
containsValue
Description copied from interface:ScriptVariableResolverChecks if this contains a value by its variable name.- Specified by:
containsValuein interfaceScriptVariableResolver- Parameters:
name- the variable name.- Returns:
- true if so, false if not.
-
getValue
Description copied from interface:ScriptVariableResolverGets the corresponding value for a variable name. Changing the returned value does not change the value, unless it is a reference type like a map or list.- Specified by:
getValuein interfaceScriptVariableResolver- Parameters:
name- the variable name.out- the destination variable for the value.- Returns:
- true if a corresponding value was fetched into out, false if not. If false, out is set to the null value.
-
setValue
Description copied from interface:ScriptVariableResolverSets a key-value pair. This should fail if the provided name corresponds to a read-only variable.- Specified by:
setValuein interfaceScriptVariableResolver- Parameters:
name- the variable name.value- the corresponding value.- See Also:
-
isReadOnly
Description copied from interface:ScriptVariableResolverChecks if an existing value is read-only.- Specified by:
isReadOnlyin interfaceScriptVariableResolver- Parameters:
name- the variable name.- Returns:
- true if so, false if not.
-
size
public int size()- Specified by:
sizein interfaceScriptVariableResolver- Returns:
- the amount of values that this maintains.
-
isEmpty
public boolean isEmpty()Description copied from interface:ScriptVariableResolverChecks if this resolver maintains no values.- Specified by:
isEmptyin interfaceScriptVariableResolver- Returns:
- true if so, false if not.
-
toString
-