KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbunit > dataset > EmptyTableDataSet


1 package org.dbunit.dataset;
2
3 /**
4  * <p> Copyright (c) 2003 OZ.COM. All Rights Reserved. </p>
5  *
6  * @author manuel.laflamme
7  * @since Mar 30, 2004
8  */

9 public class EmptyTableDataSet extends AbstractDataSet
10 {
11     private final IDataSet _dataSet;
12
13     public EmptyTableDataSet(IDataSet dataSet)
14     {
15         _dataSet = dataSet;
16     }
17
18     ////////////////////////////////////////////////////////////////////////////
19
// IDataSet interface
20

21     public String JavaDoc[] getTableNames() throws DataSetException
22     {
23         return _dataSet.getTableNames();
24     }
25
26     public ITableMetaData getTableMetaData(String JavaDoc tableName) throws DataSetException
27     {
28         return _dataSet.getTableMetaData(tableName);
29     }
30
31     public ITable getTable(String JavaDoc tableName) throws DataSetException
32     {
33         return new DefaultTable(_dataSet.getTableMetaData(tableName));
34     }
35
36     ////////////////////////////////////////////////////////////////////////////
37
// AbstractDataSet class
38

39     protected ITableIterator createIterator(boolean reversed) throws DataSetException
40     {
41         return new EmptyTableIterator(reversed ?
42                 _dataSet.reverseIterator() : _dataSet.iterator());
43     }
44
45     public static class EmptyTableIterator implements ITableIterator
46     {
47         private final ITableIterator _iterator;
48
49         public EmptyTableIterator(ITableIterator iterator)
50         {
51             _iterator = iterator;
52         }
53
54         public boolean next() throws DataSetException
55         {
56             return _iterator.next();
57         }
58
59         public ITableMetaData getTableMetaData() throws DataSetException
60         {
61             return _iterator.getTableMetaData();
62         }
63
64         public ITable getTable() throws DataSetException
65         {
66             return new DefaultTable(_iterator.getTableMetaData());
67         }
68     }
69 }
70
Popular Tags