1 21 22 package org.dbunit.dataset; 23 24 25 30 public class SortedDataSet extends AbstractDataSet 31 { 32 private final IDataSet _dataSet; 33 34 public SortedDataSet(IDataSet dataSet) throws DataSetException 35 { 36 _dataSet = dataSet; 37 } 38 39 42 protected ITableIterator createIterator(boolean reversed) 43 throws DataSetException 44 { 45 return new SortedIterator(reversed ? 46 _dataSet.reverseIterator() : _dataSet.iterator()); 47 } 48 49 52 public String [] getTableNames() throws DataSetException 53 { 54 return _dataSet.getTableNames(); 55 } 56 57 public ITableMetaData getTableMetaData(String tableName) throws DataSetException 58 { 59 return _dataSet.getTableMetaData(tableName); 60 } 61 62 public ITable getTable(String tableName) throws DataSetException 63 { 64 return new SortedTable(_dataSet.getTable(tableName)); 65 } 66 67 70 private class SortedIterator implements ITableIterator 71 { 72 private final ITableIterator _iterator; 73 74 public SortedIterator(ITableIterator iterator) 75 { 76 _iterator = iterator; 77 } 78 79 82 public boolean next() throws DataSetException 83 { 84 return _iterator.next(); 85 } 86 87 public ITableMetaData getTableMetaData() throws DataSetException 88 { 89 return _iterator.getTableMetaData(); 90 } 91 92 public ITable getTable() throws DataSetException 93 { 94 return new SortedTable(_iterator.getTable()); 95 } 96 } 97 98 } 99 100 101 102 103 104 105 | Popular Tags |