de.mguennewig.pobjects
Class PObjStack<T extends Record>

java.lang.Object
  extended by de.mguennewig.pobjects.AbstractPObjJoin<T>
      extended by de.mguennewig.pobjects.PObjStack<T>

public class PObjStack<T extends Record>
extends AbstractPObjJoin<T>

Wrapper object for stack valued joins between two tables.

Please note that the methods of this class resemble that of the standard collection class Stack, but that the semantics usually differ to some degree. In particular, every method call is an operation on the RDBMS, and the backing store's semantics do not follow those of Java. For example, given statement level read consistency on the RDBMS, a size() followed by a findAll().length may produce different results.

Even thought the methods of this stack are synchronized is there still the chance for concurrent modifications made by other database users. So you should never rely on the thrown ConcurrentModificationException.

Author:
Michael Günnewig

Constructor Summary
PObjStack(PObject parent, java.lang.Class<? extends Record> elementClass)
          Creates a new stack.
 
Method Summary
 T peek()
          Looks at the element at the top of this stack without removing it from the stack.
 T pop()
          Removes the element at the top of this stack and returns that as the value of this function.
 void push(java.lang.Object... value)
          Pushes the values value as one new element onto the top of this stack.
 void push(T obj)
          Pushes the element obj onto the top of this stack.
 
Methods inherited from class de.mguennewig.pobjects.AbstractPObjJoin
clear, findAll, getContainer, getElementClass, getElementDecl, getParent, isEmpty, size
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PObjStack

public PObjStack(PObject parent,
                 java.lang.Class<? extends Record> elementClass)
Creates a new stack.

Method Detail

push

public void push(java.lang.Object... value)
          throws PObjConstraintException,
                 PObjSQLException
Pushes the values value as one new element onto the top of this stack.

Parameters:
value - the values that construct a new element of this stack,
Throws:
java.lang.IllegalArgumentException - if not the same amount of values was given as necessary for an element of this stack. The parent and the stack position value does not count here.
PObjConstraintException - if a database constraint will be violated
PObjSQLException - if any other database error occurs
java.util.ConcurrentModificationException - if the stack has been concurrently modified
See Also:
push(Record)

push

public void push(T obj)
          throws PObjConstraintException,
                 PObjSQLException
Pushes the element obj onto the top of this stack.

Throws:
PObjConstraintException - if a database constraint will be violated
PObjSQLException - if any other database error occurs
java.util.ConcurrentModificationException - if the stack has been concurrently modified

pop

public T pop()
                     throws PObjConstraintException,
                            PObjSQLException
Removes the element at the top of this stack and returns that as the value of this function.

Throws:
PObjConstraintException - if a database constraint will be violated
PObjSQLException - if any other database error occurs
java.util.EmptyStackException - if the stack is empty
See Also:
peek()

peek

public T peek()
Looks at the element at the top of this stack without removing it from the stack.

Throws:
java.util.EmptyStackException - if the stack is empty