org.ejen
Class EjenContextsStack

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--java.util.Stack
                          |
                          +--org.ejen.EjenContextsStack
All Implemented Interfaces:
Cloneable, Collection, List, RandomAccess, Serializable

public class EjenContextsStack
extends Stack

Ejen context stack class. Defines a global context (an Hashtable) and a stack of local contexts.

Version:
1.0
Author:
F. Wolff
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
EjenContextsStack()
           
 
Method Summary
 Object globalGet(String name)
          Returns the value to which the specified name is mapped in the global context of this EjenContextsStack.
 Object globalPut(String name, Object value)
          Maps the specified name to the specified value in the global context of this EjenContextsStack.
 EjenContext peekContext()
          Looks at the EjenContext at the top of this EjenContextsStack without removing it from the stack.
 EjenContext peekContext(int index)
          Returns the EjenContext at the specified position in this EjenContextsStack.
 EjenContext popContext()
          Removes the EjenContext at the top of this EjenContextsStack and returns that EjenContext as the value of this function.
 EjenContext pushContext(EjenContext ctx)
          Pushes an EjenContext onto the top of this EjenContextsStack.
 
Methods inherited from class java.util.Stack
empty, peek, pop, push, search
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

EjenContextsStack

public EjenContextsStack()
Method Detail

peekContext

public EjenContext peekContext()
Looks at the EjenContext at the top of this EjenContextsStack without removing it from the stack.

Returns:
the EjenContext at the top of this EjenContextsStack.
Throws:
EmptyStackException - if this EjenContextsStack is empty.

peekContext

public EjenContext peekContext(int index)
Returns the EjenContext at the specified position in this EjenContextsStack.

Parameters:
index - index of EjenContext to return.
Returns:
the EjenContext at the top of this EjenContextsStack.
Throws:
ArrayIndexOutOfBoundsException - index is out of range (index < 0 || index >= size()).

popContext

public EjenContext popContext()
Removes the EjenContext at the top of this EjenContextsStack and returns that EjenContext as the value of this function.

Returns:
the EjenContext at the top of this EjenContextsStack.
Throws:
EmptyStackException - if this EjenContextsStack is empty.

pushContext

public EjenContext pushContext(EjenContext ctx)
Pushes an EjenContext onto the top of this EjenContextsStack.

Parameters:
ctx - the EjenContext to be pushed onto this EjenContextsStack.
Returns:
the ctx argument.

globalGet

public Object globalGet(String name)
Returns the value to which the specified name is mapped in the global context of this EjenContextsStack.

Parameters:
name - a name (key) in the global context (which is an Hashtable).
Returns:
the value to which the name is mapped in this global context; null if the name is not mapped to any value in this global context.

globalPut

public Object globalPut(String name,
                        Object value)
Maps the specified name to the specified value in the global context of this EjenContextsStack. Neither the name nor the value can be null.

Parameters:
name - a name (key) in the global context.
value - the value.
Returns:
the previous value of the specified name in this global context, or null if it did not have one.