de.uni_bremen.st.rcf.model
Class Relation<T extends Entry>

java.lang.Object
  extended by de.uni_bremen.st.rcf.model.Relation<T>
All Implemented Interfaces:
Iterable<T>
Direct Known Subclasses:
CloneClasses, ClonePairs, Directories, Files, Fragments, Metadatas, ProcessDatas, SourcePositions, Versions

public class Relation<T extends Entry>
extends Object
implements Iterable<T>


Method Summary
 Attribute addAttribute(String name, AttributeType type, Relation<? extends Entry> referencedRelation, boolean isList, boolean isEnum, String... enumValues)
          Creates a new attribute.
 Attribute addEnumAttribute(String name, AttributeType type, String... enumValues)
           
 Attribute addListAttribute(String name, AttributeType type)
           
 Attribute addReferenceAttribute(String name, Relation<? extends Entry> referencedRelation)
           
 Attribute addReferenceListAttribute(String name, AttributeType type, Relation<? extends Entry> referencedRelation)
           
 Attribute addScalarAttribute(String name, AttributeType type)
           
 T append()
          Append a new entry to the end of the relation and return it.
 boolean equals(Object other)
           
 Attribute getAttribute(String name)
          Get the attribute named like name.
 List<Attribute> getAttributes()
          Gets a list of the attributes of this relation.
 T getEntry(int id)
          Get the entry with the specified id
 EntryType getEntryType()
          Get the entry type all entries of this relation have.
 T getFirstEntry()
          Get the first entry of the relation.
 String getName()
          Get the relations name
 RCF getRCF()
          Get the RCF this Relation belongs to.
 boolean hasAttribute(String name)
          Check whether an attribute with the given name exists.
 RelationIterator<T> iterator()
           
 int size()
          Get the number of entries in the relation.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getName

public String getName()
Get the relations name

Returns:
the name

getRCF

public RCF getRCF()
Get the RCF this Relation belongs to.

Returns:
the RCF

getEntryType

public EntryType getEntryType()
Get the entry type all entries of this relation have.

Returns:
the entry type

getAttributes

public List<Attribute> getAttributes()
Gets a list of the attributes of this relation.

Returns:
the attribute list

addScalarAttribute

public Attribute addScalarAttribute(String name,
                                    AttributeType type)

addEnumAttribute

public Attribute addEnumAttribute(String name,
                                  AttributeType type,
                                  String... enumValues)

addReferenceAttribute

public Attribute addReferenceAttribute(String name,
                                       Relation<? extends Entry> referencedRelation)

addListAttribute

public Attribute addListAttribute(String name,
                                  AttributeType type)

addReferenceListAttribute

public Attribute addReferenceListAttribute(String name,
                                           AttributeType type,
                                           Relation<? extends Entry> referencedRelation)

addAttribute

public Attribute addAttribute(String name,
                              AttributeType type,
                              Relation<? extends Entry> referencedRelation,
                              boolean isList,
                              boolean isEnum,
                              String... enumValues)
Creates a new attribute. This method can be used to create any kind of attribute. Note that there enums of the type REFERENCE are not allowed.

Parameters:
name - Name of the Attribute
type - Type of the Attribute
referencedRelation - The relation which entries are referenced by this attribute. This is only relevant if type is REFERENCE. Pass null otherwise.
isList - If true this attribute will store a list of type
isEnum - If true the values of this Attribute will be an enumeration of type type
enumValues - The values for the enum as string representation. For booleans pass "true" or "false".
Returns:

getAttribute

public Attribute getAttribute(String name)
Get the attribute named like name.

Parameters:
name - the name
Returns:
the attribute with the given name
Throws:
NoSuchAttributeException - if no attribute with the given name exists.

hasAttribute

public boolean hasAttribute(String name)
Check whether an attribute with the given name exists.

Parameters:
name -
Returns:
true if an attribute with the given name exists.

iterator

public RelationIterator<T> iterator()
Specified by:
iterator in interface Iterable<T extends Entry>

getFirstEntry

public T getFirstEntry()
Get the first entry of the relation.

Returns:
the first entry in the relation.
Throws:
NoSuchElementException - if the relation is empty.

append

public T append()
Append a new entry to the end of the relation and return it. The values of all the entry's attributes will be unset. This is the only way to create new Entries.

Returns:
the new entry

size

public int size()
Get the number of entries in the relation.

Returns:
the number of entries

equals

public boolean equals(Object other)
Overrides:
equals in class Object

getEntry

public T getEntry(int id)
Get the entry with the specified id

Parameters:
id -
Returns:
the entry


Copyright © 2011. All Rights Reserved.