1 21 package org.dbunit.database; 22 23 import org.dbunit.dataset.*; 24 25 30 public class DatabaseTableIterator implements ITableIterator 31 { 32 private final String [] _tableNames; 33 private final IDataSet _dataSet; 34 private IResultSetTable _currentTable; 35 private int _index = -1; 36 37 public DatabaseTableIterator(String [] tableNames, IDataSet dataSet) 38 { 39 _tableNames = tableNames; 40 _dataSet = dataSet; 41 _currentTable = null; 42 } 43 44 47 public boolean next() throws DataSetException 48 { 49 _index++; 50 51 if (_currentTable != null) 53 { 54 _currentTable.close(); 55 _currentTable = null; 56 } 57 58 return _index < _tableNames.length; 59 } 60 61 public ITableMetaData getTableMetaData() throws DataSetException 62 { 63 return _dataSet.getTableMetaData(_tableNames[_index]); 64 } 65 66 public ITable getTable() throws DataSetException 67 { 68 if (_currentTable == null) 69 { 70 _currentTable = (IResultSetTable)_dataSet.getTable(_tableNames[_index]); 71 } 72 return _currentTable; 73 } 74 } 75 | Popular Tags |