public final class VariableTracker<T> extends Object
Constructor and Description |
---|
VariableTracker() |
Modifier and Type | Method and Description |
---|---|
T |
get(String name)
Get the data associated with the given variable.
|
List<T> |
getAll(String name)
Get an immutable view of all the data items associated with the specified variable.
|
int |
getOccurrenceCount(String name)
Get how many times a variable was declared in the current scope.
|
boolean |
isDeclared(String name)
Checks if the variable identified by
name is tracked by this tracker or not. |
boolean |
isEmpty()
Checks if the declaration stack is empty.
|
boolean |
isInScope(String name)
Check whether a variable was declared and is visible in the current scope.
|
Map.Entry<String,T> |
peek()
Peeks at the top of the declaration stack.
|
String |
popVariable()
Pops a variable from this tracker.
|
void |
pushVariable(String name,
T data)
Pushes a variable to this tracker.
|
public boolean isDeclared(String name)
name
is tracked by this tracker or not.name
- the name of the variabletrue
if the variable is declared, false
otherwisepublic void pushVariable(String name, T data)
name
- the name of the variabledata
- the data associated with the variablepublic String popVariable()
NoSuchElementException
- if there are no declared variables in the scopepublic Map.Entry<String,T> peek()
NoSuchElementException
- if there are no variables in scopepublic boolean isEmpty()
true
if the stack is empty, false
otherwisepublic T get(String name)
name
- the name of the variablenull
if that variable is not in scopepublic boolean isInScope(String name)
name
- the name of the variabletrue
if the variable is visible in the current scope, false
otherwisepublic List<T> getAll(String name)
name
- the name of the variablepublic int getOccurrenceCount(String name)
name
- the name of the variableCopyright © 2017 The Apache Software Foundation. All rights reserved.