public class Relation extends java.lang.Object implements java.io.Serializable, java.lang.Iterable<Attribute>
| Constructor and Description |
|---|
Relation()
Default constructor for a relation.
|
Relation(java.util.List<Attribute> attributes)
Constructs a relation given a
List of attributes. |
Relation(Relation relation)
Copy constructor for a relation.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addAttribute(Attribute attribute)
Adds an attribute to this relation.
|
Attribute |
getAttribute(int i)
Returns the specified attribute of this relation.
|
int |
getAttributeIndex(java.lang.String attr)
Given an attribute name, it returns the index of the attribute
in the relation schema.
|
int |
getNumberOfAttributes()
Returns the number of attributes of this relation.
|
java.util.Iterator<Attribute> |
iterator()
Returns an
Iterator over the attributes of this
relation. |
java.lang.String |
toString()
Textual representation.
|
public Relation()
public Relation(java.util.List<Attribute> attributes)
List of attributes.attributes - the attributes of the relation.public Relation(Relation relation)
relation - the relation to be copied.protected void addAttribute(Attribute attribute)
attribute - the attribute to be added.public int getNumberOfAttributes()
Relation's number of attributespublic java.util.Iterator<Attribute> iterator()
Iterator over the attributes of this
relation.iterator in interface java.lang.Iterable<Attribute>Relation's attribute
Iterator.public Attribute getAttribute(int i)
i - the index of the attribute to be returned.public int getAttributeIndex(java.lang.String attr)
-1 if the
attribute does not appear in the schema.attr - the attribute name-1 if the attribute does not appear in the schema.public java.lang.String toString()
toString in class java.lang.Object