import java.util.*; import java.io.*; public class TT extends RC implements Serializable { protected String SVid; protected String TTabb; protected String TTname; protected String Descr; protected TTtable Table; protected Database Schema; public TA TAid_fcp; public TA TAid_bcp; int keysize = 8; int abbrsize = 2; public void setSVid(String value) { SVid = value; } public String getSVid() { return SVid; } void setTTabb(String value) { TTabb = value; } public String getTTabb() { return TTabb; } void setTTname(String value) { TTname = value; } public String getTTname() { return TTname; } void setDescr(String value) { Descr = value; } public String getDescr() { return Descr; } public TTtable getTable() { return Table; } public void setTable(TTtable value) { Table = value; } public Database getSchema() { return Schema; } public void setSchema(Database value) { Schema = value; } TT(String rowbuffer, Database mySchema) { String buffer; StringTokenizer tokens = new StringTokenizer( rowbuffer ); buffer = tokens.nextToken(); pkid = new Key(buffer, mySchema); buffer = tokens.nextToken(); SVid = buffer; buffer = tokens.nextToken(); TTabb = buffer; buffer = tokens.nextToken(); TTname = buffer; // We allow spaces in the last one, so // this has to be a bit different buffer = tokens.nextToken("\r\n"); Descr = buffer.trim(); Schema = mySchema; Table = mySchema.TTtab; } public void addRow() { Table.insertRow(this); linkRow(); } public void deleteRow() { Table.removeRow(this); unlinkRow(); } public void linkRow() { TA TAcurr; TA TAtemp; for( TAcurr = Schema.TAtab.getFirstRow(); TAcurr != null; TAcurr = Schema.TAtab.getNextRow(TAcurr) ) { if( TAcurr.getTTid().compare( pkid ) == 0 ) { TAcurr.TTid_pp = this; TAtemp = TAid_bcp; TAid_bcp = TAcurr; TAcurr.TTid_fpp = this; if ( TAid_fcp == null ) { TAid_fcp = TAcurr; TAcurr.TTid_bpp = this; } else { TAcurr.TTid_bpp = TAtemp; TAtemp.TTid_fpp = TAcurr; } // End else } // End if == } // End for } public void unlinkRow() { RC TAtemp; RC TAtemp2; TAtemp = TAid_fcp; while( ( TAtemp != null ) && ( TAtemp != this ) ) { TAtemp2 = ((TA)TAtemp).TTid_fpp; ((TA)TAtemp).TTid_bpp = ((TA)TAtemp).TTid_fpp = ((TA)TAtemp).TTid_pp = null; TAtemp = TAtemp2; } } public TT() { } public void dumpRow(BufferedWriter output) throws IOException { output.write(this.toString()); output.newLine(); output.flush(); } public String toString() { return pkid + " " + SVid + " " + TTabb + " " + TTname + " " + Descr; } public static void main(String[] args) { String line = "SV010001 PJ010001 test_de_co.sch CHGEN v9.0 CHGEN"; TT theTable = new TT(); // tt theTable = new TT(line); System.out.println("pkid = " + theTable.getPkid()); System.out.println("SVid = " + theTable.getSVid()); System.out.println("TTname = " + theTable.getTTname()); System.out.println("TTabb = " + theTable.getTTabb()); System.out.println("Descr = " + theTable.getDescr()); } }