1 21 22 package org.dbunit.dataset; 23 24 import org.dbunit.dataset.filter.ITableFilter; 25 import org.dbunit.dataset.filter.SequenceTableFilter; 26 27 39 public class FilteredDataSet extends AbstractDataSet 40 { 41 private final IDataSet _dataSet; 42 private final ITableFilter _filter; 43 44 49 public FilteredDataSet(String [] tableNames, IDataSet dataSet) 50 { 51 _filter = new SequenceTableFilter(tableNames); 52 _dataSet = dataSet; 53 } 54 55 62 public FilteredDataSet(ITableFilter filter, IDataSet dataSet) 63 { 64 _dataSet = dataSet; 65 _filter = filter; 66 } 67 68 71 protected ITableIterator createIterator(boolean reversed) 72 throws DataSetException 73 { 74 return _filter.iterator(_dataSet, reversed); 75 } 76 77 80 public String [] getTableNames() throws DataSetException 81 { 82 return _filter.getTableNames(_dataSet); 83 } 84 85 public ITableMetaData getTableMetaData(String tableName) 86 throws DataSetException 87 { 88 if (!_filter.accept(tableName)) 89 { 90 throw new NoSuchTableException(tableName); 91 } 92 93 return _dataSet.getTableMetaData(tableName); 94 } 95 96 public ITable getTable(String tableName) throws DataSetException 97 { 98 if (!_filter.accept(tableName)) 99 { 100 throw new NoSuchTableException(tableName); 101 } 102 103 return _dataSet.getTable(tableName); 104 } 105 } 106 107 108 109 110 111 112 113 | Popular Tags |