|                                                                                                              1
 24
 25  package com.mckoi.database;
 26
 27
 40
 41  abstract class AbstractInternalTableInfo2 implements InternalTableInfo {
 42
 43
 46    protected final Transaction transaction;
 47
 48
 52    protected final TableName table_name;
 53
 54
 57    public AbstractInternalTableInfo2(Transaction transaction,
 58                                      TableName table_name) {
 59      this.transaction = transaction;
 60      this.table_name = table_name;
 61    }
 62
 63    public int getTableCount() {
 64      if (transaction.tableExists(table_name)) {
 65        return transaction.getTable(table_name).getRowCount();
 66      }
 67      else {
 68        return 0;
 69      }
 70    }
 71
 72    public int findTableName(TableName name) {
 73      if (transaction.realTableExists(table_name)) {
 74                    MutableTableDataSource table = transaction.getTable(table_name);
 77        RowEnumeration row_e = table.rowEnumeration();
 78        int p = 0;
 79        while (row_e.hasMoreRows()) {
 80          int row_index = row_e.nextRowIndex();
 81          TObject ob_name = table.getCellContents(1, row_index);
 82          if (ob_name.getObject().toString().equals(name.getName())) {
 83            TObject ob_schema = table.getCellContents(0, row_index);
 84            if (ob_schema.getObject().toString().equals(name.getSchema())) {
 85                          return p;
 87            }
 88          }
 89          ++p;
 90        }
 91      }
 92      return -1;
 93    }
 94
 95    public TableName getTableName(int i) {
 96      if (transaction.realTableExists(table_name)) {
 97                    MutableTableDataSource table = transaction.getTable(table_name);
 100       RowEnumeration row_e = table.rowEnumeration();
 101       int p = 0;
 102       while (row_e.hasMoreRows()) {
 103         int row_index = row_e.nextRowIndex();
 104         if (i == p) {
 105           TObject ob_schema = table.getCellContents(0, row_index);
 106           TObject ob_name = table.getCellContents(1, row_index);
 107           return new TableName(ob_schema.getObject().toString(),
 108                                ob_name.getObject().toString());
 109         }
 110         ++p;
 111       }
 112     }
 113     throw new RuntimeException
  ("Out of bounds."); 114   }
 115
 116   public boolean containsTableName(TableName name) {
 117                 if (name.equals(table_name)) {
 121       return false;
 122     }
 123     else {
 124       return findTableName(name) != -1;
 125     }
 126   }
 127
 128   public abstract DataTableDef getDataTableDef(int i);
 129
 130   public abstract String
  getTableType(int i); 131
 132   public abstract MutableTableDataSource createInternalTable(int index);
 133
 134 }
 135
 136
                                                                                                                                                                                                             |                                                                       
 
 
 
 
 
                                                                                   Popular Tags                                                                                                                                                                                              |