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

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

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

Wrapper object for set valued joins between two tables.

Please note that the methods of this class resemble that of the standard collection class Set, 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.


Constructor Summary
PObjSet(PObject parent, java.lang.Class<? extends Record> elementClass)
          Creates a new set.
 
Method Summary
 void add(java.lang.Object... key)
          Add the given arguments as an element to the set.
 boolean addIfAbsent(java.lang.Object... key)
          Add the given arguments as an element to the set if no such already exists.
 boolean contains(java.lang.Object... key)
          Return true if the given key exists in this set.
 T find(java.lang.Object... key)
          Return the set element matching the given key, or null if no such row exists.
 boolean remove(java.lang.Object... key)
          Remove the given arguments as an element from the set.
 boolean remove(T obj)
          Remove the give record obj as an element from the set.
 
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

PObjSet

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

Method Detail

find

public T find(java.lang.Object... key)
Return the set element matching the given key, or null if no such row exists.

Throws:
java.lang.IllegalArgumentException - if key.length != pk.length-1.

contains

public boolean contains(java.lang.Object... key)
Return true if the given key exists in this set.

Throws:
java.lang.IllegalArgumentException - if key.length != pk.length-1.

add

public void add(java.lang.Object... key)
         throws PObjConstraintException,
                PObjSQLException
Add the given arguments as an element to the set. It is an error if the element already exists. The data is stored immediately in the RDBMS. In this, the add() method resembles store() on a newly created PObject.

Throws:
PObjConstraintException
PObjSQLException

addIfAbsent

public final boolean addIfAbsent(java.lang.Object... key)
                          throws PObjConstraintException,
                                 PObjSQLException
Add the given arguments as an element to the set if no such already exists.

Returns:
true if an element has been added to this set, otherwise false
Throws:
java.lang.IllegalArgumentException - if key.length != pk.length-1.
PObjConstraintException
PObjSQLException
See Also:
contains(Object[]), add(Object[])

remove

public boolean remove(T obj)
               throws PObjConstraintException,
                      PObjSQLException
Remove the give record obj as an element from the set. If the element exists prior to the call, then the result is true. The data is stored immediately in the RDBMS. In this, the add() method resembles store() on a delete PObject.

Throws:
PObjConstraintException
PObjSQLException

remove

public boolean remove(java.lang.Object... key)
               throws PObjConstraintException,
                      PObjSQLException
Remove the given arguments as an element from the set. If the element exists prior to the call, then the result is true. The data is stored immediately in the RDBMS. In this, the add() method resembles store() on a deleted PObject.

Throws:
PObjConstraintException
PObjSQLException