- java.lang.Object
- 
- edu.uiuc.ncsa.security.core.state.SStack<V>
 
- 
- All Implemented Interfaces:
- Serializable
 - Direct Known Subclasses:
- EnvStack
 
 public abstract class SStack<V extends STable<? extends SKey,? extends SThing>> extends Object implements Serializable A stateful stack of things, such as functions. This is the method by which local state is preserved. The zero-th element is the current local table. It is used for entries., hence the prefix of S for it and things related to it.UsageCreate a subclass as needed for your objects. This involves an SStack,STable,SKeyand anSThing.How state is managedIf we had the following QDL:f(x)->x^2; block[f(x)->x^3;...]ThenSStacksubclass for functions inside the block would look liketable entry 0 f(x)->x^3 1 f(x)->x^2Calls toget(SKey)would peek at 0 and return f(x)->x^3 inside the block. This is how local state overrides the parent state. Blocks of course can be for loops, functions, conditionals etc. Were there no entry for f(x) in the block, thenSStackwould return f(x)->x^2.Created by Jeff Gaynor 
 on 11/8/21 at 6:27 AM- See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classSStack.ROMapA read-only map that virtualizes this stack.
 - 
Constructor SummaryConstructors Constructor Description SStack()
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddTables(SStack sStack)Take an SStack and prepend in the correct order to the front of the stack.List<SKey>allKeys()Returns the a list of keys (including redundancies) for this stack.voidappend(V v)Append the table to the end of the stack -- this sets the root for the table.voidappendTables(SStack sStack)Similar toaddTables(SStack), but this appends them to the existing set of tables.voidclear()Clears the entire stack and resets it.SStackclone()booleancontainsKey(SKey key)booleancontainsKey(SKey key, int startTableIndex)Check that a specific key is in a table starting at the index.SThingget(SKey key)Get the value from someplace in the stack.List<? extends SThing>getAll()Get all of the values from all tables.This returns a flat list.Map<String,String>getAsMap()Get a read only virtualization of this stack as a map.STable<? extends SKey,? extends SThing>getLocal()Get the local table for this stack.STable<? extends SKey,? extends SThing>getRoot()Since all new tables are added at 0, the initial one, called the root, is last.List<STable<? extends SKey,? extends SThing>>getStack()booleanisEmpty()Set<SKey>keySet()Returns the unique set of keys over the tables.SThinglocalGet(SKey key)Only returns a non-null element if it is defined in the local (index 0) table.booleanlocalHas(SKey xkey)SThinglocalPut(SThing value)Only add this to the local state.voidlocalRemove(SKey key)Removes only the most local entry.abstract SStacknewInstance()abstract STablenewTableInstance()SThingnonlocalGet(SKey key)searches for the entry every place except the most local state.STable<SKey,SThing>peek()STable<SKey,SThing>pop()Remove the most local table.voidpush(STable<? extends SKey,? extends SThing> sTable)voidpushNewTable()SThingput(SKey sKey, SThing xThing)SThingput(SThing value)voidremove(SKey key)Removes all references from all tables.voidsetStack(List<STable<? extends SKey,? extends SThing>> stack)intsize()StringtoString()StringtoString(boolean showKeys)
 
- 
- 
- 
Method Detail- 
clearpublic void clear() Clears the entire stack and resets it.
 - 
addTablespublic void addTables(SStack sStack) Take an SStack and prepend in the correct order to the front of the stack. If SStack is [A,B,C,...] And the existing stack is [P,Q,...] the result is [A,B,C,...,P,Q,...] This is needed when, e.g., creating new local state for function reference resolution
 Note:get(SKey)starts from index 0, so local overrides are first!- Parameters:
- sStack-
 
 - 
appendTablespublic void appendTables(SStack sStack) Similar toaddTables(SStack), but this appends them to the existing set of tables. If SStack is [A,B,C,...] And the existing stack is [P,Q,...] the result is [P,Q,...,A,B,C,...,]
 Note:get(SKey)starts from index 0, so local overrides are first!- Parameters:
- sStack-
 
 - 
newInstancepublic abstract SStack newInstance() 
 - 
newTableInstancepublic abstract STable newTableInstance() 
 - 
appendpublic void append(V v) Append the table to the end of the stack -- this sets the root for the table.- Parameters:
- v-
 
 - 
containsKeypublic boolean containsKey(SKey key, int startTableIndex) Check that a specific key is in a table starting at the index. This lets you, e.g., skip local state if the start index is positive.- Parameters:
- key-
- startTableIndex-
- Returns:
 
 - 
containsKeypublic boolean containsKey(SKey key) 
 - 
localGetpublic SThing localGet(SKey key) Only returns a non-null element if it is defined in the local (index 0) table.- Parameters:
- key-
- Returns:
 
 - 
getLocalpublic STable<? extends SKey,? extends SThing> getLocal() Get the local table for this stack.- Returns:
 
 - 
localHaspublic boolean localHas(SKey xkey) 
 - 
getpublic SThing get(SKey key) Get the value from someplace in the stack. This returns first found so manages the overrides in the scope. Note that local calls (e.g.localGet(SKey)only look in the current scope.- Parameters:
- key-
- Returns:
 
 - 
nonlocalGetpublic SThing nonlocalGet(SKey key) searches for the entry every place except the most local state.- Parameters:
- key-
- Returns:
 
 - 
getAllpublic List<? extends SThing> getAll() Get all of the values from all tables.This returns a flat list.- Returns:
 
 - 
getRootpublic STable<? extends SKey,? extends SThing> getRoot() Since all new tables are added at 0, the initial one, called the root, is last. This gets the rootSTable.- Returns:
 
 - 
isEmptypublic boolean isEmpty() 
 - 
pushNewTablepublic void pushNewTable() 
 - 
localPutpublic SThing localPut(SThing value) Only add this to the local state.- Parameters:
- value-
- Returns:
 
 - 
localRemovepublic void localRemove(SKey key) Removes only the most local entry.- Parameters:
- key-
 
 - 
removepublic void remove(SKey key) Removes all references from all tables. This includes all overrides so at the end of this operation there are no references any place.- Parameters:
- key-
 
 - 
sizepublic int size() 
 - 
toStringpublic String toString(boolean showKeys) 
 - 
allKeyspublic List<SKey> allKeys() Returns the a list of keys (including redundancies) for this stack.- Returns:
 
 
- 
 
-