be.SIRAPRISE.client
Class AbstractTupleBag

java.lang.Object
  extended by be.SIRAPRISE.client.AbstractTupleContainer
      extended by be.SIRAPRISE.client.AbstractTupleBag
All Implemented Interfaces:
TupleBag, TupleContainer, java.lang.Iterable<Tuple>
Direct Known Subclasses:
InsertionOrderTupleBag

public abstract class AbstractTupleBag
extends AbstractTupleContainer
implements TupleBag

Abstract implementation of the TupleBag interface

Author:
Erwin Smout

Constructor Summary
AbstractTupleBag(Heading heading, java.util.List<Tuple> list)
          Creates the TupleBag
 
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 t)
          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
 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
equals, getClass, hashCode, 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

AbstractTupleBag

public AbstractTupleBag(Heading heading,
                        java.util.List<Tuple> list)
Creates the TupleBag

Parameters:
heading - The Heading that all tuples in the bag must be guaranteed to conform to
list - The list underlying the Collection behaviour of the TupleBag
Method Detail

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.

addTupleWithoutHeadingCheck

public final void addTupleWithoutHeadingCheck(Tuple t)
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:
t - The tuple to be added to the container

clear

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

Specified by:
clear in interface TupleContainer

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

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

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

removeTuple

public 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

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.