theseus.api
Class Relation

java.lang.Object
  |
  +--theseus.api.Relation
All Implemented Interfaces:
java.io.Serializable

public final class Relation
extends java.lang.Object
implements java.io.Serializable

Relations consist of a name, attribute list, and a set of tuples.

See Also:
Serialized Form

Constructor Summary
Relation(java.lang.String a_name)
          Create relation with only a name (no attribute list).
Relation(java.lang.String a_name, theseus.api.AttrList a_attrList)
          Create relation using predefined attribute list.
Relation(java.lang.String a_name, theseus.api.AttrList a_attrList, theseus.api.TupleSet a_tset)
          Create relation with name, attribute list, and tuple set.
Relation(java.lang.String a_name, java.lang.String a_attrList)
          Create relation from string description.
 
Method Summary
 void addTuple(theseus.api.Tuple a_row)
          Add a tuple to the relation.
 void addTupleAndAttr(theseus.api.Tuple a_row)
          Add a tuple to the relation, set the attribute list with tuple attributes if Relation attribute list was already null.
 java.lang.Object clone()
           
 theseus.api.AttrList getAttrList()
          Get the attribute list of the relation.
 java.lang.String getName()
          Get the name of the relation.
 theseus.api.TupleSet getTupleSet()
          Get the set of tuples in the relation.
static theseus.api.Relation[] loadFromFile(java.lang.String a_filename)
          Loads relation from an external datafile.
 void setAttrList(theseus.api.AttrList attrList)
          Set the attribute list for the relation (NOTE: existing tuples are not back-checked for compatibility).
 java.lang.String toString()
          String form of relation.
 theseus.api.Relation union(theseus.api.Relation a_rel)
          Union two relations (no duplicates).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Relation

public Relation(java.lang.String a_name,
                java.lang.String a_attrList)
         throws theseus.api.InvalidAttrListException
Create relation from string description. For example, the following is possible: new Relation("myrel", "name char, age number").


Relation

public Relation(java.lang.String a_name,
                theseus.api.AttrList a_attrList)
Create relation using predefined attribute list.


Relation

public Relation(java.lang.String a_name)
Create relation with only a name (no attribute list).


Relation

public Relation(java.lang.String a_name,
                theseus.api.AttrList a_attrList,
                theseus.api.TupleSet a_tset)
Create relation with name, attribute list, and tuple set.

Method Detail

addTuple

public void addTuple(theseus.api.Tuple a_row)
Add a tuple to the relation.


addTupleAndAttr

public void addTupleAndAttr(theseus.api.Tuple a_row)
Add a tuple to the relation, set the attribute list with tuple attributes if Relation attribute list was already null.


getName

public java.lang.String getName()
Get the name of the relation.


getAttrList

public theseus.api.AttrList getAttrList()
Get the attribute list of the relation.


getTupleSet

public theseus.api.TupleSet getTupleSet()
Get the set of tuples in the relation.


setAttrList

public void setAttrList(theseus.api.AttrList attrList)
Set the attribute list for the relation (NOTE: existing tuples are not back-checked for compatibility).


toString

public java.lang.String toString()
String form of relation.

Overrides:
toString in class java.lang.Object

union

public theseus.api.Relation union(theseus.api.Relation a_rel)
Union two relations (no duplicates). Type compatibility is currently not enforced.


loadFromFile

public static theseus.api.Relation[] loadFromFile(java.lang.String a_filename)
                                           throws theseus.api.DatafileImportException
Loads relation from an external datafile. The format of the datafile must be like:
 RELATION [name]: [attr1-name] [attr1type], ...
 [tuple1-attr1-value]|[tuple1-attr2-value]|...
 ...
 RELATION [name2]...
 ...
 
Comment lines are those that start with an '#'.

theseus.api.DatafileImportException

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object