proper.relaggs
Class RelaggsTable

java.lang.Object
  extended by proper.relaggs.RelaggsTable
All Implemented Interfaces:
java.lang.Comparable

public class RelaggsTable
extends java.lang.Object
implements java.lang.Comparable

Title: RelaggsTable Description: Represents a table. Copyright: (c) 2002 Susanne Streuer

Version:
$Revision: 1.2 $
Author:
Susanne Streuer, FracPete

Field Summary
static java.lang.String SHORT_NAME_PREFIX
          The general short name prefix.
static java.lang.String SHORT_NAME_PREFIX_TMP
          The temporary short name prefix.
 
Constructor Summary
RelaggsTable(java.lang.String table_name)
          Creates a new RelaggsTable with the given name.
 
Method Summary
 boolean addAttribute(RelaggsAttribute attribute)
          Adds a new attribute to the table.
 void addForeignKey(RelaggsTable ref_table)
          Adds the foreign keys to the given table (if exist) to the table.
 boolean addPrimaryKey(java.lang.String prim_key)
          Adds a primary key to the table.
 java.lang.Object clone()
          Returns a clone of the table.
 int compareTo(java.lang.Object o)
          Compares another table to this table.
 boolean equals(java.lang.Object obj)
          Returns true if the object is a RelaggsTable object and the name equals this one.
 RelaggsAttribute getAttribute(java.lang.String name)
          returns the attribute object for the given name.
 java.util.Enumeration getAttributes()
          Returns an Enumeration of the attributes (RelaggsAttribute objects) of the table.
 java.util.Iterator getAttributesOrdered()
          Returns an Iterator of the attributes (RelaggsAttribute objects) of the table in alphabetic order.
 int getColumnCount()
          returns the number of columns currently in this table
 java.util.HashSet getColumns()
          returns the HashSet containing the current columns in this table
 int getMaxColumns()
          returns the max number of columns for a table, -1 means uninitialized
 java.lang.String getName()
          Returns the name of the table.
 int getNumberAttributes()
          Returns the number of attributes of the table.
 int getNumForeignKeys()
          Returns the number of foreign keys of the table.
 java.util.Enumeration getPrimaryKeys()
          Returns an Enumeration of the primary key attributes (RelaggsAttribute objects) of the table.
 int getRowNumber()
          Returns the number of rows of the table.
 java.lang.String getShortName()
          Returns the short name of the table.
 boolean hasForeignKey(RelaggsTable ref_table)
          Returns whether the table references the given table by foreign key or not.
 boolean isAttribute(java.lang.String attribute_name)
          Returns whether the given attribute is a attribute of the table (true) or not (false).
 boolean isForeignKey(java.lang.String attribute_name)
          Returns whether the given attribute is a foreign key of the table (true) or not (false).
 boolean isPrimaryKey(java.lang.String attribute_name)
          Returns whether the given attribute is a primary key of the table (true) or not (false).
 void setMaxColumns(int maxColumns)
          sets the number of max columns for a table
 void setRowNumber(int value)
          Sets the number of rows for the table.
 void setShortName(int number)
          Sets the short name of the table to the general short name prefix followed by the given number.
 void setShortName(int number, boolean is_tmp)
          Sets the short name of the table to the general short name prefix followed by the given number if the table is a regular table.
 void setShortName(java.lang.String short_name)
          Sets the short name of the table to the given name.
 java.lang.String toString()
          Returns the name of the table.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SHORT_NAME_PREFIX

public static final java.lang.String SHORT_NAME_PREFIX
The general short name prefix.

See Also:
Constant Field Values

SHORT_NAME_PREFIX_TMP

public static final java.lang.String SHORT_NAME_PREFIX_TMP
The temporary short name prefix.

See Also:
Constant Field Values
Constructor Detail

RelaggsTable

public RelaggsTable(java.lang.String table_name)
Creates a new RelaggsTable with the given name.

Parameters:
table_name - name of the table
Method Detail

setMaxColumns

public void setMaxColumns(int maxColumns)
sets the number of max columns for a table


getMaxColumns

public int getMaxColumns()
returns the max number of columns for a table, -1 means uninitialized


getColumns

public java.util.HashSet getColumns()
returns the HashSet containing the current columns in this table


getColumnCount

public int getColumnCount()
returns the number of columns currently in this table


toString

public java.lang.String toString()
Returns the name of the table.

Overrides:
toString in class java.lang.Object

setRowNumber

public void setRowNumber(int value)
Sets the number of rows for the table.

Parameters:
value - the number of rows

getRowNumber

public int getRowNumber()
Returns the number of rows of the table.


setShortName

public void setShortName(java.lang.String short_name)
Sets the short name of the table to the given name.

Parameters:
short_name - the new short name

setShortName

public void setShortName(int number)
Sets the short name of the table to the general short name prefix followed by the given number.

Parameters:
number - the number that is appended to the general short name prefix

setShortName

public void setShortName(int number,
                         boolean is_tmp)
Sets the short name of the table to the general short name prefix followed by the given number if the table is a regular table. If the table is temporary then the temporary short name prefix is used follewed by the number.

Parameters:
number - the number that is appended
is_tmp - flag defining whether the table is temporary (true) or not (false)

getShortName

public java.lang.String getShortName()
Returns the short name of the table.


hasForeignKey

public boolean hasForeignKey(RelaggsTable ref_table)
Returns whether the table references the given table by foreign key or not.

Parameters:
ref_table - the table that should be referenced by this table
Returns:
true if the table references the given table; else false

getPrimaryKeys

public java.util.Enumeration getPrimaryKeys()
Returns an Enumeration of the primary key attributes (RelaggsAttribute objects) of the table. (Not alphabetically ordered.)


addAttribute

public boolean addAttribute(RelaggsAttribute attribute)
Adds a new attribute to the table.

Parameters:
attribute - the attribute to add
Returns:
true if attribute was added; false if the attribute already exists

addPrimaryKey

public boolean addPrimaryKey(java.lang.String prim_key)
Adds a primary key to the table. Only the reference not the attribute. The primary key attribute has to be added as an attribute before.

Parameters:
prim_key - the name of the primary key attribute
Returns:
true if primary key was added; false if the primary key already exists or if the attribute is missing

addForeignKey

public void addForeignKey(RelaggsTable ref_table)
Adds the foreign keys to the given table (if exist) to the table.

Parameters:
ref_table - the table that is referenced in this table by a foreign key (is not neccessary)

clone

public java.lang.Object clone()
Returns a clone of the table.

Overrides:
clone in class java.lang.Object

getAttributes

public java.util.Enumeration getAttributes()
Returns an Enumeration of the attributes (RelaggsAttribute objects) of the table. (Not alphabetically ordered.)


getAttributesOrdered

public java.util.Iterator getAttributesOrdered()
Returns an Iterator of the attributes (RelaggsAttribute objects) of the table in alphabetic order.


getAttribute

public RelaggsAttribute getAttribute(java.lang.String name)
returns the attribute object for the given name. returns null if it cannot be found.

Parameters:
name - the name of the attribute to retrieve
Returns:
the attribute object, if it was found

getName

public java.lang.String getName()
Returns the name of the table.


getNumberAttributes

public int getNumberAttributes()
Returns the number of attributes of the table.


getNumForeignKeys

public int getNumForeignKeys()
Returns the number of foreign keys of the table.


isPrimaryKey

public boolean isPrimaryKey(java.lang.String attribute_name)
Returns whether the given attribute is a primary key of the table (true) or not (false).

Parameters:
attribute_name - the name of the attribute to check

isForeignKey

public boolean isForeignKey(java.lang.String attribute_name)
Returns whether the given attribute is a foreign key of the table (true) or not (false).

Parameters:
attribute_name - the name of the attribute to check

isAttribute

public boolean isAttribute(java.lang.String attribute_name)
Returns whether the given attribute is a attribute of the table (true) or not (false).

Parameters:
attribute_name - the name of the attribute to check

equals

public boolean equals(java.lang.Object obj)
Returns true if the object is a RelaggsTable object and the name equals this one.

Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(java.lang.Object o)
Compares another table to this table.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the object to compare
Returns:
a negative integer, zero, or a positive integer as this table name is alphabetically less than, equal to, or greater than the specified table name