proper.database
Class Table

java.lang.Object
  extended by proper.database.Table
All Implemented Interfaces:
java.lang.Comparable, Assignable

public class Table
extends java.lang.Object
implements java.lang.Comparable, Assignable

This class contains some static informations about a table, like name and size. It can sorted differently, either by name or size.

Version:
$Revision: 1.2 $
Author:
FracPete

Constructor Summary
Table(java.lang.String name)
          initializes the object
Table(java.lang.String name, int size)
          initializes the object
 
Method Summary
 void assign(java.lang.Object o)
          retrieves the inner state of the given object and updates its own state with those settings
 int compareTo(java.lang.Object o)
          compares the given object to itself, depending on the sorting
 java.lang.String createForeignKeyStatement(Column localCol, Table foreignTable, Column foreignCol)
          generates an SQL statement for adding a foreign key to this table.
static java.lang.String createForeignKeyStatement(Table localTable, Column localCol, Table foreignTable, Column foreignCol)
          generates an SQL statement for adding a foreign key to this table.
 boolean equals(java.lang.Object obj)
          checks whether the objects are the same
 java.lang.String getName()
          returns the name of the table
 int getSize()
          returns the size (in records) of the table
 boolean getSortByName()
          returns whether the sorting is done by name (= TRUE) or by size (= FALSE)
static void main(java.lang.String[] args)
          for testing only
 void setSize(int size)
          sets the size (in records) of the table
 void setSortByName(boolean sortByName)
          sets whether the sorting is done by name (= TRUE) or by size (= FALSE)
 java.lang.String toString()
          just returns the name of the table
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Table

public Table(java.lang.String name)
initializes the object


Table

public Table(java.lang.String name,
             int size)
initializes the object

Method Detail

getName

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


setSize

public void setSize(int size)
sets the size (in records) of the table


getSize

public int getSize()
returns the size (in records) of the table


setSortByName

public void setSortByName(boolean sortByName)
sets whether the sorting is done by name (= TRUE) or by size (= FALSE)


getSortByName

public boolean getSortByName()
returns whether the sorting is done by name (= TRUE) or by size (= FALSE)


compareTo

public int compareTo(java.lang.Object o)
compares the given object to itself, depending on the sorting

Specified by:
compareTo in interface java.lang.Comparable

equals

public boolean equals(java.lang.Object obj)
checks whether the objects are the same

Overrides:
equals in class java.lang.Object

createForeignKeyStatement

public java.lang.String createForeignKeyStatement(Column localCol,
                                                  Table foreignTable,
                                                  Column foreignCol)
generates an SQL statement for adding a foreign key to this table. has a ";" at the end.

Parameters:
localCol - the local column that references
foreignTable - the foreign table the key is lcoated in
foreignCol - the column in the foreign table
Returns:
the "ALTER TABLE" SQL statement

createForeignKeyStatement

public static java.lang.String createForeignKeyStatement(Table localTable,
                                                         Column localCol,
                                                         Table foreignTable,
                                                         Column foreignCol)
generates an SQL statement for adding a foreign key to this table. has a ";" at the end.

Parameters:
localTable - the local table that references the foreign table
localCol - the local column that references
foreignTable - the foreign table the key is lcoated in
foreignCol - the column in the foreign table
Returns:
the "ALTER TABLE" SQL statement

assign

public void assign(java.lang.Object o)
retrieves the inner state of the given object and updates its own state with those settings

Specified by:
assign in interface Assignable
Parameters:
o - the object to retrieve the inner state from

toString

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

Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
for testing only