|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.onemind.commons.java.datastructure.NametableStack
public class NametableStack
A nametable stack contains key-value mapping that has a scope. A new scope can be opened for putting new mappings and all the mappings added in this scope can be wiped out easily with a closeScope command. In effect this is like a stack of Maps, hence the name NametableStack. NOTE: the implementation use a map and list to achieve the behaviour.
| Nested Class Summary | |
|---|---|
private static class |
NametableStack.LocalNametable
The local nametable defines a scope where local variables mask out the global variables, but the global variable can still be accessed. |
| Field Summary | |
|---|---|
private java.util.ArrayList |
_list
the list of maps * |
private static java.util.logging.Logger |
_logger
the logger * |
private Nametable |
_nametable
the map * |
| Constructor Summary | |
|---|---|
NametableStack()
|
|
NametableStack(java.util.Map m)
|
|
| Method Summary | |
|---|---|
java.lang.Object |
access(java.lang.String name)
Resolve the value associated with key name |
java.util.Map |
asMap()
Return map representation of the nametable stack |
java.lang.Object |
assign(java.lang.String name,
java.lang.Object value)
Assign name/value pair |
void |
closeLocalScope(int i)
|
void |
closeScope(int l)
Close a scope |
boolean |
containsName(java.lang.String name)
Whether the map contains key name |
void |
declare(java.lang.String name,
java.lang.Object value)
Declare name value pair |
int |
newLocalScope()
|
int |
newScope()
Open a new scope for mappings. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final java.util.logging.Logger _logger
private Nametable _nametable
private java.util.ArrayList _list
| Constructor Detail |
|---|
public NametableStack()
public NametableStack(java.util.Map m)
m - the initial mapping| Method Detail |
|---|
public int newScope()
public int newLocalScope()
public void closeLocalScope(int i)
public void closeScope(int l)
l - the scope id
public void declare(java.lang.String name,
java.lang.Object value)
name - value -
public java.lang.Object assign(java.lang.String name,
java.lang.Object value)
name - value -
public java.lang.Object access(java.lang.String name)
name - the key
public boolean containsName(java.lang.String name)
name - the key
public java.util.Map asMap()
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||