// Generated by Together
package oisoft.togetherx.scripts.SQL.impl;
import java.util.Enumeration;
import COM.objectspace.jgl.UnaryFunction;
import oisoft.togetherx.scripts.SQL.SQLTable;
class ForeignKeyImpl implements oisoft.togetherx.scripts.SQL.SQLForeignKey {
ForeignKeyImpl(TableImpl table, SQLTable referencedTable, boolean forcePrimaryKey){
myTable = table;
myReferencedTable = referencedTable;
myForcePrimaryKey = forcePrimaryKey;
}
public SQLTable getTable(){
return myTable;
}
public String getName(){
return myTable.getForeignKeyName(this);
}
public Enumeration getColumns(){
boolean showForeign = !myTable.equals(getReferencedTable());
UnaryFunction filter
= new UnaryFunction(){
public Object execute(Object arg){
if( !(arg instanceof ColumnImpl) ){
return null;
}
else{
return myTable.getForeignKeyColumn((ColumnImpl)arg, myForcePrimaryKey);
}
}
};
Enumeration source = null;
if( getReferencedTable() instanceof TableImpl ){
source = ((TableImpl)getReferencedTable()).getPrimaryKeyColumns(showForeign);
}
else{
source = new EmptyEnumeration();
}
return new FilterEnumeration(source, filter);
}
public SQLTable getReferencedTable(){
return myReferencedTable;
}
public Enumeration getReferencedColumns(){
return getReferencedTable().getPrimaryKeyColumns();
}
private TableImpl myTable;
private SQLTable myReferencedTable;
private boolean myForcePrimaryKey;
}
|