arlut.csd.Util
Class NamedStack

java.lang.Object
  |
  +--arlut.csd.Util.NamedStack

public final class NamedStack
extends java.lang.Object

NamedStack is a data structure that allows named items to be placed on a stack. When it comes time to pop data off the stack, the pop operation takes the name of the item to be popped, and all items pushed on the stack after the named item will also be popped.

That is, NamedStack is basically a Stack that supports rollback to a named state. It is used in the Ganymede server to support checkpoint operations.

NamedStack does not require that names of pushed items be unique. A pop operation will simply pop up to the last item matching the given name off the stack.


Field Summary
private  java.util.Stack stack
           
 
Constructor Summary
NamedStack()
           
 
Method Summary
 java.lang.Object elementAt(int index)
           
 boolean empty()
           
 int findName(java.lang.String name)
          findName() returns the top-most index at which the name is present in the named object stack, or -1 if the name was not found.
 java.lang.String getTopName()
          This method returns the name associated with the last item pushed onto this name stack, without altering the stack.
 java.lang.Object getTopObject()
          This method returns the object associated with the last item pushed onto this name stack, without altering the stack.
 java.lang.String nameAt(int index)
           
 java.lang.Object pop()
          This is just plain old pop, it will return the top element without regard to its name.
 java.lang.Object pop(java.lang.String name)
          pop rolls the state of the stack back to the time just before the top-most named object matching name was pushed.
 java.lang.Object push(java.lang.String name, java.lang.Object item)
          push pushes a named item onto the stack.
 void removeAllElements()
           
 int size()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

stack

private java.util.Stack stack
Constructor Detail

NamedStack

public NamedStack()
Method Detail

push

public java.lang.Object push(java.lang.String name,
                             java.lang.Object item)

push pushes a named item onto the stack.


pop

public java.lang.Object pop(java.lang.String name)

pop rolls the state of the stack back to the time just before the top-most named object matching name was pushed.


pop

public java.lang.Object pop()

This is just plain old pop, it will return the top element without regard to its name.


elementAt

public java.lang.Object elementAt(int index)

nameAt

public java.lang.String nameAt(int index)

size

public int size()

removeAllElements

public void removeAllElements()

getTopName

public java.lang.String getTopName()

This method returns the name associated with the last item pushed onto this name stack, without altering the stack.


getTopObject

public java.lang.Object getTopObject()

This method returns the object associated with the last item pushed onto this name stack, without altering the stack.


findName

public int findName(java.lang.String name)

findName() returns the top-most index at which the name is present in the named object stack, or -1 if the name was not found.


empty

public boolean empty()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object