1 /*
2 *
3 * The DbUnit Database Testing Framework
4 * Copyright (C)2002-2004, DbUnit.org
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21 package org.dbunit.dataset.stream;
22
23 import org.dbunit.dataset.AbstractDataSet;
24 import org.dbunit.dataset.DataSetException;
25 import org.dbunit.dataset.ITable;
26 import org.dbunit.dataset.ITableIterator;
27 import org.dbunit.dataset.ITableMetaData;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30
31 /**
32 * Dataset that consumes producer asynchronously.
33 *
34 * @author Manuel Laflamme
35 * @author Last changed by: $Author$
36 * @version $Revision$ $Date$
37 * @since Apr 18, 2003
38 */
39 public class StreamingDataSet extends AbstractDataSet
40 {
41
42 /**
43 * Logger for this class
44 */
45 private static final Logger logger = LoggerFactory.getLogger(StreamingDataSet.class);
46
47 private IDataSetProducer _source;
48 private int _iteratorCount;
49
50 public StreamingDataSet(IDataSetProducer source)
51 {
52 _source = source;
53 }
54
55 ////////////////////////////////////////////////////////////////////////////
56 // AbstractDataSet class
57
58 protected ITableIterator createIterator(boolean reversed)
59 throws DataSetException
60 {
61 logger.debug("createIterator(reversed={}) - start", Boolean.valueOf(reversed));
62
63 if (reversed)
64 {
65 throw new UnsupportedOperationException(
66 "Reverse iterator not supported!");
67 }
68
69 if (_iteratorCount > 0)
70 {
71 throw new UnsupportedOperationException(
72 "Only one iterator allowed!");
73 }
74
75 _iteratorCount++;
76 return new StreamingIterator(_source);
77 }
78
79 ////////////////////////////////////////////////////////////////////////////
80 // IDataSet interface
81
82 /**
83 * Not supported.
84 * @throws UnsupportedOperationException
85 */
86 public String[] getTableNames() throws DataSetException
87 {
88 throw new UnsupportedOperationException();
89 }
90
91 /**
92 * Not supported.
93 * @throws UnsupportedOperationException
94 */
95 public ITableMetaData getTableMetaData(String tableName) throws DataSetException
96 {
97 logger.debug("getTableMetaData(tableName={}) - start", tableName);
98
99 throw new UnsupportedOperationException();
100 }
101
102 /**
103 * Not supported.
104 * @throws UnsupportedOperationException
105 */
106 public ITable getTable(String tableName) throws DataSetException
107 {
108 logger.debug("getTable(tableName={}) - start", tableName);
109
110 throw new UnsupportedOperationException();
111 }
112
113 }