FileDocCategorySizeDatePackage
TableConstraintEnumeration.javaAPI DocExample1749Tue Dec 08 01:21:00 GMT 1998oisoft.togetherx.scripts.SQL.impl

TableConstraintEnumeration

public class TableConstraintEnumeration extends Object implements Enumeration

Fields Summary
private TableImpl
myTable
private Enumeration
myPrimaryKeyFields
private boolean
myPrimaryKeyPassed
private Enumeration
myForeignKeys
private Object
myCurrent
Constructors Summary
public TableConstraintEnumeration(TableImpl table)


    
    myTable = table;
    advance();
  
Methods Summary
private voidadvance()

    myCurrent = null;
    if( hasPrimaryKey() ){
      myPrimaryKeyPassed = true;
      Enumeration primaryKeyFields = getPrimaryKeyFields();
      if( primaryKeyFields.hasMoreElements() ){
        myCurrent = new PrimaryKeyImpl(myTable,primaryKeyFields);
      }
    }
    while(myCurrent == null && getForeignKeys().hasMoreElements() ){
      ForeignKeyImpl tmp = (ForeignKeyImpl)getForeignKeys().nextElement();
      if(tmp.getColumns().hasMoreElements()){
        myCurrent = tmp;
      }
    }
  
private java.util.EnumerationgetForeignKeys()

    if(myForeignKeys == null){
      myForeignKeys = new ForeignKeyEnumeration(myTable,(SQLModelImpl)myTable.getModel());
    }
    return myForeignKeys;
  
private java.util.EnumerationgetPrimaryKeyFields()

    if(myPrimaryKeyFields == null){
      myPrimaryKeyFields = myTable.getPrimaryKeyColumns();
    }
    return myPrimaryKeyFields;
  
public booleanhasMoreElements()

    return myCurrent != null;
  
private booleanhasPrimaryKey()

    return !myPrimaryKeyPassed && getPrimaryKeyFields().hasMoreElements();
  
public java.lang.ObjectnextElement()

    Object result = myCurrent;
    advance();
    return result;