01: /**
02: * ===========================================
03: * JFreeReport : a free Java reporting library
04: * ===========================================
05: *
06: * Project Info: http://reporting.pentaho.org/
07: *
08: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
09: *
10: * This library is free software; you can redistribute it and/or modify it under the terms
11: * of the GNU Lesser General Public License as published by the Free Software Foundation;
12: * either version 2.1 of the License, or (at your option) any later version.
13: *
14: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16: * See the GNU Lesser General Public License for more details.
17: *
18: * You should have received a copy of the GNU Lesser General Public License along with this
19: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20: * Boston, MA 02111-1307, USA.
21: *
22: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
23: * in the United States and other countries.]
24: *
25: * ------------
26: * DataFactory.java
27: * ------------
28: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
29: */package org.jfree.report;
30:
31: import javax.swing.table.TableModel;
32:
33: /**
34: * Creates a tablemodel on request. If the returned tablemodel is a {@link org.jfree.report.util.CloseableTableModel}
35: * the tablemodel must remain open until the DataFactory remains open. The TableModel should not be disposed until the
36: * data-factory has been closed.
37: *
38: * @author Thomas Morgner
39: */
40: public interface DataFactory {
41: /**
42: * Queries a datasource. The string 'query' defines the name of the query. The Parameterset given here may contain
43: * more data than actually needed for the query.
44: * <p/>
45: * The parameter-dataset may change between two calls, do not assume anything, and do not hold references to the
46: * parameter-dataset or the position of the columns in the dataset.
47: *
48: * @param query the query string
49: * @param parameters the parameters for the query
50: * @return the result of the query as table model.
51: * @throws ReportDataFactoryException if an error occured while performing the query.
52: */
53: public TableModel queryData(final String query,
54: final DataRow parameters) throws ReportDataFactoryException;
55:
56: /**
57: * Returns a copy of the data factory that is not affected by its anchestor and holds no connection to the anchestor
58: * anymore. A data-factory will be derived at the beginning of the report processing.
59: *
60: * @return a copy of the data factory.
61: * @throws ReportDataFactoryException if an error occured.
62: */
63: public DataFactory derive() throws ReportDataFactoryException;
64:
65: /**
66: * Opens the data factory. This initializes everything. Performing queries on data factories which have not yet been
67: * opened will result in exceptions.
68: */
69: public void open();
70:
71: /**
72: * Closes the data factory and frees all resources held by this instance.
73: */
74: public void close();
75: }
|