import java.util.*;
import java.text.DecimalFormat;
import java.io.*;
/**
* Teacher Tab
* @author Genjava v1.0
*/
public class TE extends RC implements Serializable
{
protected String name;
protected TEtable Table;
protected Database Schema;
public RS RSid_fcp;
public RS RSid_bcp;
TE(String rowbuffer, Database mySchema)
{
String buffer;
StringTokenizer tokens =
new StringTokenizer( rowbuffer );
buffer = tokens.nextToken();
pkid = new Key(buffer, mySchema);
buffer = tokens.nextToken("\r\n");
name = buffer.trim();
Schema = mySchema;
Table = mySchema.TEtab;
}
TE()
{
}
/**
* Retrieves the value of name
*/
public String getname()
{
return name;
}
/**
* Sets the value of name
*/
public void setname(String value)
{
name = value;
}
/**
* Retrieves a reference to the TEtable
*/
public TEtable getTable()
{
return Table;
}
/**
* Sets the reference to the TEtable
*/
public void setTable(TEtable value)
{
Table = value;
}
/**
* Retrieves a reference to the global schema
*/
public Database getSchema()
{
return Schema;
}
/**
* Modifies the reference to the global schema
*/
public void setSchema(Database value)
{
Schema = value;
}
/**
* Adds this TE to its Table * and links it to its parents and siblings
*/
public void addRow()
{
if( Table.insertRow(this) )
linkRow();
}
/**
* Removes this TE from its Table * and unlinks it from its parents and siblings
*/
public void deleteRow()
{
if( Table.removeRow(this) )
unlinkRow();
}
/**
* Links this TE to all of it's related tables
*/
public void linkRow()
{
// Locals for parent tables
// Locals for child tables
RS RSctemp;
RS RSccurr;
// This loop basically implements link_child_bp_m
for( RSccurr = Schema.RStab.getFirstRow();
RSccurr != null;
RSccurr = Schema.RStab.getNextRow(RSccurr) ) {
if( RSccurr.getTEid().compare(pkid) == 0 ) {
RSccurr.TEid_pp = this;
RSctemp = RSid_bcp;
RSid_bcp = RSccurr;
RSccurr.TEid_fpp = this;
if ( RSid_fcp == null ) {
RSid_fcp = RSccurr;
RSccurr.TEid_bpp = this;
}
else {
RSccurr.TEid_bpp = RSctemp;
RSctemp.TEid_fpp = RSccurr;
} // End else
} // End if ==
} // End for
}
/**
* Unlinks this TE from all of it's related tables
*/
public void unlinkRow()
{
// Locals for parent tables
// Locals for child tables
RC RCtemp;
RC RCtemp2;
RCtemp = RSid_fcp;
while( ( RCtemp != null ) && ( RCtemp != this ) ) {
RCtemp2 = ((RS)RCtemp).TEid_fpp;
((RS)RCtemp).TEid_bpp = ((RS)RCtemp).TEid_pp =
((RS)RCtemp).TEid_pp = null;
RCtemp = RCtemp2;
}
}
/**
* Writes this TE to a given BufferedWriter
*/
public void dumpRow(BufferedWriter output) throws IOException
{
output.write(this.toString());
output.newLine();
output.flush();
}
public String toString()
{
return pkid + " " + name;
}
}