001: /*
002: *
003: * The DbUnit Database Testing Framework
004: * Copyright (C)2002-2004, DbUnit.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: */
021: package org.dbunit.dataset.stream;
022:
023: import org.slf4j.Logger;
024: import org.slf4j.LoggerFactory;
025:
026: import org.dbunit.dataset.*;
027:
028: /**
029: * Dataset that consumes producer asyncronously.
030: *
031: * @author Manuel Laflamme
032: * @since Apr 18, 2003
033: * @version $Revision: 554 $
034: */
035: public class StreamingDataSet extends AbstractDataSet {
036:
037: /**
038: * Logger for this class
039: */
040: private static final Logger logger = LoggerFactory
041: .getLogger(StreamingDataSet.class);
042:
043: private IDataSetProducer _source;
044: private int _iteratorCount;
045:
046: public StreamingDataSet(IDataSetProducer source) {
047: _source = source;
048: }
049:
050: ////////////////////////////////////////////////////////////////////////////
051: // AbstractDataSet class
052:
053: protected ITableIterator createIterator(boolean reversed)
054: throws DataSetException {
055: logger.debug("createIterator(reversed=" + reversed
056: + ") - start");
057:
058: if (reversed) {
059: throw new UnsupportedOperationException(
060: "Reverse iterator not supported!");
061: }
062:
063: if (_iteratorCount > 0) {
064: throw new UnsupportedOperationException(
065: "Only one iterator allowed!");
066: }
067:
068: _iteratorCount++;
069: return new StreamingIterator(_source);
070: }
071:
072: ////////////////////////////////////////////////////////////////////////////
073: // IDataSet interface
074:
075: /**
076: * Not supported.
077: * @throws UnsupportedOperationException
078: */
079: public String[] getTableNames() throws DataSetException {
080: logger.debug("getTableNames() - start");
081:
082: throw new UnsupportedOperationException();
083: }
084:
085: /**
086: * Not supported.
087: * @throws UnsupportedOperationException
088: */
089: public ITableMetaData getTableMetaData(String tableName)
090: throws DataSetException {
091: logger.debug("getTableMetaData(tableName=" + tableName
092: + ") - start");
093:
094: throw new UnsupportedOperationException();
095: }
096:
097: /**
098: * Not supported.
099: * @throws UnsupportedOperationException
100: */
101: public ITable getTable(String tableName) throws DataSetException {
102: logger.debug("getTable(tableName=" + tableName + ") - start");
103:
104: throw new UnsupportedOperationException();
105: }
106:
107: }
|