be.SIRAPRISE.client
Class AbstractRelation

java.lang.Object
  extended by be.SIRAPRISE.client.AbstractTupleContainer
      extended by be.SIRAPRISE.client.AbstractRelation
All Implemented Interfaces:
Relation, TupleContainer, java.lang.Iterable<Tuple>
Direct Known Subclasses:
InsertionOrderRelation, OrderedRelation

public abstract class AbstractRelation
extends AbstractTupleContainer
implements Relation

The AbstractRelation provides an implementation for the Relation interface

Author:
Erwin Smout

Constructor Summary
AbstractRelation(Heading heading, java.util.Set<Tuple> set)
          Creates the container, setting the intended heading for the tuples and the underlying Set object
 
Method Summary
abstract  boolean addOK(Tuple tuple)
          "exit" method called by the addTuple() methods to check if it is OK to add the given tuple to this relation.
 void addTupleWithoutHeadingCheck(Tuple tuple)
          Adds a Tuple to the container without checking the conformance of the tuple to the declared heading.
 void clear()
          Empties the TupleContainer
 boolean containsTuple(Tuple t)
          Checks whether the given tuple appears in this container
 boolean containsTuples(TupleContainer tupleContainer)
          Checks whether all tuples that appear in the given container also appear in this one
 boolean equals(java.lang.Object obj)
           
 java.util.Set<Tuple> getTupleSet()
          Gets The set of Tuple objects constituting this relation value.
 int hashCode()
           
 java.util.Iterator<Tuple> iterator()
          Gets an iterator over the tuples in the container
 boolean removeTuple(Tuple t)
          Removes the given tuple from this container if that tuple appears there
 int size()
          Gets The number of tuples that appear in the relation.
 
Methods inherited from class be.SIRAPRISE.client.AbstractTupleContainer
addTuplesWithHeadingCheck, addTuplesWithoutHeadingCheck, addTupleWithHeadingCheck, getHeading, printBodyEscapedWithBodyHeaderWithoutTypeNames, printBodyEscapedWithBodyHeaderWithTypeNames, printBodyEscapedWithoutBodyHeaderWithoutTypeNames, printBodyEscapedWithoutBodyHeaderWithTypeNames, printBodyWithBodyHeaderWithoutTypeNames, printBodyWithBodyHeaderWithTypeNames, printBodyWithoutBodyHeaderWithoutTypeNames, printBodyWithoutBodyHeaderWithTypeNames, printBodyXMLWithBodyHeader, printBodyXMLWithoutBodyHeader, printValueEscapedWithoutTypeNames, printValueEscapedWithTypeNames, printValueWithoutTypeNames, printValueWithTypeNames, printValueXML, removeTuples, toObjectArray, toObjectArrayIgnoringMissingSetters, toObjectCollection, toObjectCollectionIgnoringMissingSetters, toObjectsArray, toObjectsCollection, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface be.SIRAPRISE.client.TupleContainer
addTuplesWithHeadingCheck, addTuplesWithoutHeadingCheck, addTupleWithHeadingCheck, getHeading, printValueEscapedWithoutTypeNames, printValueEscapedWithTypeNames, printValueWithoutTypeNames, printValueWithTypeNames, printValueXML, removeTuples, toObjectArray, toObjectArrayIgnoringMissingSetters, toObjectCollection, toObjectCollectionIgnoringMissingSetters, toObjectsArray, toObjectsCollection
 

Constructor Detail

AbstractRelation

public AbstractRelation(Heading heading,
                        java.util.Set<Tuple> set)
Creates the container, setting the intended heading for the tuples and the underlying Set object

Parameters:
heading - The heading for tuple container.
set - The Set object that will give us the Set interface methods. The behaviour of the iterator() method (in particular the iteration order) will be determined by the type of Set that is passed to this method.
Method Detail

addTupleWithoutHeadingCheck

public final void addTupleWithoutHeadingCheck(Tuple tuple)
Description copied from class: AbstractTupleContainer
Adds a Tuple to the container without checking the conformance of the tuple to the declared heading. The conformance should be guaranteed externally to this method.

Specified by:
addTupleWithoutHeadingCheck in interface TupleContainer
Specified by:
addTupleWithoutHeadingCheck in class AbstractTupleContainer
Parameters:
tuple - The tuple to be added to the container

addOK

public abstract boolean addOK(Tuple tuple)
"exit" method called by the addTuple() methods to check if it is OK to add the given tuple to this relation. This method should return false only in very specific circumstances.

Parameters:
tuple - The tuple about to be added to the relation.
Returns:
true if it is OK to add the tuple to the given relation.

containsTuples

public final boolean containsTuples(TupleContainer tupleContainer)
Description copied from interface: TupleContainer
Checks whether all tuples that appear in the given container also appear in this one

Specified by:
containsTuples in interface TupleContainer
Parameters:
tupleContainer - The tuple container whose tuples must all be contained in this one for the method to return true
Returns:
true if all tuples that appear in the given container also appear in this one

containsTuple

public final boolean containsTuple(Tuple t)
Description copied from interface: TupleContainer
Checks whether the given tuple appears in this container

Specified by:
containsTuple in interface TupleContainer
Parameters:
t - The tuple value to be tested for presence in the container
Returns:
true if the tuple value is present in this container

equals

public final boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getTupleSet

public final java.util.Set<Tuple> getTupleSet()
Description copied from interface: Relation
Gets The set of Tuple objects constituting this relation value.

Specified by:
getTupleSet in interface Relation
Returns:
The set of Tuple objects constituting this relation value.

hashCode

public final int hashCode()
Overrides:
hashCode in class java.lang.Object

iterator

public final java.util.Iterator<Tuple> iterator()
Description copied from class: AbstractTupleContainer
Gets an iterator over the tuples in the container

Specified by:
iterator in interface TupleContainer
Specified by:
iterator in interface java.lang.Iterable<Tuple>
Specified by:
iterator in class AbstractTupleContainer
Returns:
an iterator over the tuples in the container

size

public final int size()
Description copied from interface: TupleContainer
Gets The number of tuples that appear in the relation.

Specified by:
size in interface TupleContainer
Specified by:
size in class AbstractTupleContainer
Returns:
The number of tuples that appear in the relation.

removeTuple

public final boolean removeTuple(Tuple t)
Description copied from interface: TupleContainer
Removes the given tuple from this container if that tuple appears there

Specified by:
removeTuple in interface TupleContainer
Specified by:
removeTuple in class AbstractTupleContainer
Parameters:
t - The tuple to be removed from the container
Returns:
true if the tuple was removed, false if it was not found in this TupleContainer

clear

public final void clear()
Description copied from interface: TupleContainer
Empties the TupleContainer

Specified by:
clear in interface TupleContainer