01: /**
02: * com.mckoi.database.TableDataSource 17 Nov 2000
03: *
04: * Mckoi SQL Database ( http://www.mckoi.com/database )
05: * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * Version 2 as published by the Free Software Foundation.
10: *
11: * This program 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
14: * GNU General Public License Version 2 for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * Version 2 along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19: *
20: * Change Log:
21: *
22: *
23: */package com.mckoi.database;
24:
25: /**
26: * This interface represents the source of data in a table. This is an
27: * abstraction that is used to read data from within a table.
28: * <p>
29: * The entire contents of a table can be completely represented by
30: * implementations of this interface.
31: *
32: * @author Tobias Downer
33: */
34:
35: public interface TableDataSource {
36:
37: /**
38: * Returns the TransactionSystem object that describes global properties
39: * about the data source that generated this object.
40: */
41: TransactionSystem getSystem();
42:
43: /**
44: * Returns a DataTableDef object that defines the layout of the table that
45: * this data is in.
46: * <p>
47: * This may return 'null' if there is no table definition.
48: */
49: DataTableDef getDataTableDef();
50:
51: /**
52: * Returns the number of rows in this data source.
53: * <p>
54: * NOTE: Returns 'n' - getCellContents(column, row) is not necessarily valid
55: * for row = [0..n]. Use 'rowEnumerator' to generate an iterator for valid
56: * row values over this data source.
57: */
58: int getRowCount();
59:
60: /**
61: * Returns an iterator that is used to sequentually step through all valid
62: * rows in this source. The iterator is guarenteed to return exactly
63: * 'getRowCount' elements. The row elements returned by this iterator
64: * are used in 'getCellContents' in the 'row' parameter.
65: * <p>
66: * Note that this object is only defined if entries in the table are not
67: * added/remove during the lifetime of this iterator. If entries are added
68: * or removed from the table while this iterator is open, then calls to
69: * 'nextRowIndex' will be undefined.
70: */
71: RowEnumeration rowEnumeration();
72:
73: /**
74: * Returns the SelectableScheme that we use as an index for rows in the
75: * given column of this source. The SelectableScheme is used to determine
76: * the relationship between cells in a column.
77: * <p>
78: * ISSUE: The scheme returned here should not have the 'insert' or 'remove'
79: * methods called (ie. it should be considered immutable). Perhaps we
80: * should make a MutableSelectableScheme interface to guarentee this
81: * constraint.
82: */
83: SelectableScheme getColumnScheme(int column);
84:
85: /**
86: * Returns an object that represents the information in the given cell
87: * in the table. This may be an expensive operation, so calls to it
88: * should be kept to a minimum. Note that the offset between two
89: * rows is not necessarily 1. Use 'rowEnumeration' to create a row iterator.
90: */
91: TObject getCellContents(int column, int row);
92:
93: }
|