gishur.core
Class Stack

java.lang.Object
  |
  +--gishur.core.BasicList
        |
        +--gishur.core.Stack
All Implemented Interfaces:
java.lang.Cloneable, Cloneable, ControlledCloneable, Owner, java.io.Serializable

public class Stack
extends BasicList
implements ControlledCloneable

A simple stack based upon BasicList.

Version:
1.0
Author:
Thomas Wolf
See Also:
BasicList, Serialized Form

Fields inherited from class gishur.core.BasicList
ANY_ACCESS, KEY, LISTITEM, NO_ACCESS, VALUE
 
Fields inherited from interface gishur.core.ControlledCloneable
DEEP, FLAT
 
Constructor Summary
Stack()
          Empty constructor calling BasicList.BasicList().
 
Method Summary
 java.lang.Object bottom()
          Retunrs the lower (first) element of the Stack.
 void clear()
          Clears the whole Stack.
 java.lang.Object clone()
          Implementation of gishur.core.Cloneable
clones the entire list by cloning the contained data-/keyobjects, if possible.
 java.lang.Object clone(java.util.Hashtable h, int level)
          clones the entire list according to gishur.core.ControlledClonebale.
 boolean contains(java.lang.Object object)
          Returns true if this Stack contains object.
 java.lang.Object[] convertToArray()
          Converts the Stack into an array.
 java.util.Enumeration elements()
          Returns a java.util.Enumeration-object enumerating the Stack's elements.
 boolean empty()
          Returns true if the Stack is empty.
 ListView getListView()
          Creates a ListView-object enabling complete read access to the Stack without knowing its explicite type.
 int length()
          Returns the number of stored elements in the Stack.
 java.lang.Object peek()
          Works the same way like top().
 java.lang.Object pop()
          Removes the last element from the Stack and returns it.
 boolean popBoolean()
          pop() for boolean-values.
 double popDouble()
          pop() for double-values.
 float popFloat()
          pop() for float-values.
 int popInt()
          pop() for int-values.
 long popLong()
          pop() for long-values.
 void push(boolean b)
          push(java.lang.Object) for boolean-values.
 void push(double d)
          push(java.lang.Object) for double-values.
 void push(float f)
          push(java.lang.Object) for float-values.
 void push(int i)
          push(java.lang.Object) for int-values.
 void push(long l)
          push(java.lang.Object) for long-values.
 void push(java.lang.Object object)
          Stores an object on the stack.
 java.lang.Object top()
          Returns the upper (last) elements of the Stack.
 java.lang.String toString()
          Overrides java.lang.Object.toString().
 
Methods inherited from class gishur.core.BasicList
add, add, allowAccess, contains, copy, copy, copy, cut, cycle, cycle, enumerate, equals, find, findClass, findClosest, first, getDistance, getIndex, getListItem, getListItemArray, getListString, last, move, reconnect, reconnect, remove, requestAccess, reverse, storeInArray, toString, unconnect
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Stack

public Stack()
Empty constructor calling BasicList.BasicList().
Method Detail

toString

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

clone

public java.lang.Object clone()
Implementation of gishur.core.Cloneable
clones the entire list by cloning the contained data-/keyobjects, if possible. If not possible, the references to the data-/keyobjects are maintained.
Specified by:
clone in interface Cloneable
Overrides:
clone in class java.lang.Object
Returns:
a clone of this object.
Throws:
InternalError - - if the Object could not be cloned properly

clone

public java.lang.Object clone(java.util.Hashtable h,
                              int level)
clones the entire list according to gishur.core.ControlledClonebale. That means, all ListItems are cloned and connected proper.
For further details about level see also ControlledCloneable
Specified by:
clone in interface ControlledCloneable
Overrides:
clone in class BasicList
Parameters:
h - Hashtable to indicate which objects are already cloned (see also: ControlledCloneable)
level - indicates how deep the objects should be cloned (see also: ControlledCloneable)
Returns:
cloned object
Throws:
InternalError - - if the Object could not be cloned properly

length

public int length()
Returns the number of stored elements in the Stack.
Overrides:
length in class BasicList
Returns:
number of stored elements

empty

public boolean empty()
Returns true if the Stack is empty.
Overrides:
empty in class BasicList
Returns:
true if Stack is empty

contains

public boolean contains(java.lang.Object object)
Returns true if this Stack contains object.
Parameters:
object - the object to search for in the Stack
Returns:
true, if object is part of this stack

bottom

public java.lang.Object bottom()
Retunrs the lower (first) element of the Stack. If the Stack is empty, a ListException will occur.
Returns:
the Stack's first element

top

public java.lang.Object top()
Returns the upper (last) elements of the Stack. If the Stack is empty, a ListException will occur.
Returns:
the Stack's last element

peek

public java.lang.Object peek()
Works the same way like top().
Returns:
the Stack's last element
See Also:
top()

push

public void push(java.lang.Object object)
Stores an object on the stack.
Parameters:
object - to push onto the stack

pop

public java.lang.Object pop()
Removes the last element from the Stack and returns it. The last element is that one which was last added to the Stack.
Returns:
the Stack's last element

clear

public void clear()
Clears the whole Stack.
Overrides:
clear in class BasicList

convertToArray

public java.lang.Object[] convertToArray()
Converts the Stack into an array. The lowest (first) element of the Stack will be the array's first element.
Returns:
an array of type Object containing the Stack's objects in their former order

elements

public java.util.Enumeration elements()
Returns a java.util.Enumeration-object enumerating the Stack's elements. The Stack's lowest (first) element will be the first element of the Enumeration and so on.
Returns:
Enumeration enumerating this Stack

getListView

public ListView getListView()
Creates a ListView-object enabling complete read access to the Stack without knowing its explicite type.
Overrides:
getListView in class BasicList
Returns:
ListView for read access

push

public void push(int i)
push(java.lang.Object) for int-values.
Parameters:
i - the int to be pushed onto the Stack
See Also:
push(java.lang.Object)

push

public void push(long l)
push(java.lang.Object) for long-values.
Parameters:
l - the long to be pushed onto the Stack
See Also:
push(java.lang.Object)

push

public void push(float f)
push(java.lang.Object) for float-values.
Parameters:
f - the float to be pushed onto the Stack
See Also:
push(java.lang.Object)

push

public void push(double d)
push(java.lang.Object) for double-values.
Parameters:
d - the double to be pushed onto the Stack
See Also:
push(java.lang.Object)

push

public void push(boolean b)
push(java.lang.Object) for boolean-values.
Parameters:
i - the boolean to be pushed onto the Stack
See Also:
push(java.lang.Object)

popInt

public int popInt()
pop() for int-values. If the object on top the Stack cannot be converted into an int, a ListException will occur.
Returns:
the Stack's last object as an int-value
See Also:
pop()

popLong

public long popLong()
pop() for long-values. If the object on top the Stack cannot be converted into a long, a ListException will occur.
Returns:
the Stack's last object as an long-value
See Also:
pop()

popFloat

public float popFloat()
pop() for float-values. If the object on top the Stack cannot be converted into a flaot, a ListException will occur.
Returns:
the Stack's last object as an float-value
See Also:
pop()

popDouble

public double popDouble()
pop() for double-values. If the object on top the Stack cannot be converted into a double, a ListException will occur.
Returns:
the Stack's last object as an double-value
See Also:
pop()

popBoolean

public boolean popBoolean()
pop() for boolean-values. If the object on top the Stack cannot be converted into a boolean, a ListException will occur.
Returns:
the Stack's last object as an boolean-value
See Also:
pop()