1 21 package org.dbunit.dataset; 22 23 30 public class ForwardOnlyDataSet extends AbstractDataSet 31 { 32 private final IDataSet _dataSet; 33 private int _iteratorCount; 34 35 public ForwardOnlyDataSet(IDataSet dataSet) 36 { 37 _dataSet = dataSet; 38 } 39 40 43 protected ITableIterator createIterator(boolean reversed) 44 throws DataSetException 45 { 46 if (reversed) 47 { 48 throw new UnsupportedOperationException ( 49 "Reverse iterator not supported!"); 50 } 51 52 if (_iteratorCount > 0) 53 { 54 throw new UnsupportedOperationException ( 55 "Only one iterator allowed!"); 56 } 57 58 return new ForwardOnlyIterator(_dataSet.iterator()); 59 } 60 61 64 public String [] getTableNames() throws DataSetException 65 { 66 throw new UnsupportedOperationException (); 67 } 68 69 public ITableMetaData getTableMetaData(String tableName) throws DataSetException 70 { 71 throw new UnsupportedOperationException (); 72 } 73 74 public ITable getTable(String tableName) throws DataSetException 75 { 76 throw new UnsupportedOperationException (); 77 } 78 79 82 private class ForwardOnlyIterator implements ITableIterator 83 { 84 private final ITableIterator _iterator; 85 86 public ForwardOnlyIterator(ITableIterator iterator) 87 { 88 _iterator = iterator; 89 _iteratorCount++; 90 } 91 92 95 public boolean next() throws DataSetException 96 { 97 return _iterator.next(); 98 } 99 100 public ITableMetaData getTableMetaData() throws DataSetException 101 { 102 return _iterator.getTableMetaData(); 103 } 104 105 public ITable getTable() throws DataSetException 106 { 107 return new ForwardOnlyTable(_iterator.getTable()); 108 } 109 } 110 } 111 | Popular Tags |