Package com.blackrook.expression
Class ExpressionVariableContext
- java.lang.Object
-
- com.blackrook.expression.ExpressionVariableContext
-
- All Implemented Interfaces:
ExpressionVariableSet
public class ExpressionVariableContext extends Object implements ExpressionVariableSet
An open variable set in which values can be set. The internals are written so that the storage uses few memory allocations/deletions.- Author:
- Matthew Tropiano
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_CAPACITY
Default capacity.
-
Constructor Summary
Constructors Constructor Description ExpressionVariableContext()
Creates a context with a default size.ExpressionVariableContext(int capacity)
Creates a context with a default size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears the context.ExpressionValue
get(String name)
Gets a corresponding expression value by name.boolean
isEmpty()
void
set(String name, boolean value)
Gets a corresponding expression value by name.void
set(String name, double value)
Gets a corresponding expression value by name.void
set(String name, long value)
Gets a corresponding expression value by name.void
set(String name, ExpressionValue value)
Gets a corresponding expression value by name.int
size()
String
toString()
-
-
-
Field Detail
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITY
Default capacity.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ExpressionVariableContext
public ExpressionVariableContext()
Creates a context with a default size.- See Also:
DEFAULT_CAPACITY
-
ExpressionVariableContext
public ExpressionVariableContext(int capacity)
Creates a context with a default size.- Parameters:
capacity
- the initial capacity.
-
-
Method Detail
-
clear
public void clear()
Clears the context.
-
get
public ExpressionValue get(String name)
Description copied from interface:ExpressionVariableSet
Gets a corresponding expression value by name.- Specified by:
get
in interfaceExpressionVariableSet
- Parameters:
name
- the name of the variable.- Returns:
- the value or null if no variable.
-
set
public void set(String name, boolean value)
Gets a corresponding expression value by name.- Parameters:
name
- the name of the variable.value
- the value to set.
-
set
public void set(String name, long value)
Gets a corresponding expression value by name.- Parameters:
name
- the name of the variable.value
- the value to set.
-
set
public void set(String name, double value)
Gets a corresponding expression value by name.- Parameters:
name
- the name of the variable.value
- the value to set.
-
set
public void set(String name, ExpressionValue value)
Gets a corresponding expression value by name.- Parameters:
name
- the name of the variable.value
- the value to set.
-
size
public int size()
- Returns:
- the amount of variables maintained by this context.
-
isEmpty
public boolean isEmpty()
- Returns:
- true if this has no variables, false of not.
-
-