View Javadoc

1   /***
2    * Report.java
3    *
4    * This file is part of the creme library.
5    * The creme library intends to ease the development effort of large
6    * applications by providing easy to use support classes.
7    *
8    * Copyright (C) 2002 Denis Bregeon
9    *
10   * This library is free software; you can redistribute it and/or
11   * modify it under the terms of the GNU Lesser General Public
12   * License as published by the Free Software Foundation; either
13   * version 2.1 of the License, or (at your option) any later version.
14   *
15   * This library is distributed in the hope that it will be useful,
16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18   * Lesser General Public License for more details.
19   *
20   * You should have received a copy of the GNU Lesser General Public
21   * License along with this library; if not, write to the Free Software
22   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23   *
24   * contact information: dbregeon@sourceforge.net
25   */
26  package org.jcreme.reporting;
27  
28  import org.jcreme.filters.ReportFilter;
29  
30  /***
31   * This class enables to describe a report that is presented as a table. This
32   * interface makes it quick and easy to plug a report in a TableModel. Classes
33   * that implement this interface should be careful not to reference any GUI
34   * class or object, so that they can be used in a graphic free environment (such
35   * as a unix webserver for instance).
36   * 
37   * @author $Author: dbregeon $
38   * @version $Revision: 1.2 $
39   */
40  public interface Report {
41      /***
42       * This method enables to access the title of the Report. This title may
43       * change when the filter changes.
44       * 
45       * @return the title of the Report.
46       */
47      String getTitle();
48  
49      /***
50       * This method enables to get the names of the columns present in the
51       * Report.
52       * 
53       * @return the column names of the report.
54       */
55      String[] getColumnNames();
56  
57      /***
58       * This method enables to get the column index from its name. This is
59       * necessary since values must be accessed by row index and column index.
60       * 
61       * @param columnName
62       *            the name of the column for which we search the index.
63       * @return the particular index of a column.
64       */
65      int getColumnIndex(String columnName);
66  
67      /***
68       * This is a convenience method to recover the name of the column from its
69       * index.
70       * 
71       * @param index
72       *            the index of the column for which we search the name.
73       * @return the name of a column at a particular index.
74       */
75      String getColumnName(int index);
76  
77      /***
78       * This enables to know the range of values for the column indexes.
79       * 
80       * @return the number of columns in the report.
81       */
82      int getColumnCount();
83  
84      /***
85       * This enables to know the range of values for the row indexes.
86       * 
87       * @return the number of rows in the report.
88       */
89      int getRowCount();
90  
91      /***
92       * This method gives access to the value at the given row and column for
93       * this report.
94       * 
95       * @param row
96       *            the row for which we want a value.
97       * @param column
98       *            the column for which we want a value.
99       * @return the value in the report for the particular row and the particular
100      *         column.
101      */
102     Object getValueAt(int row, int column);
103 
104     /***
105      * Adds a listener to the report.
106      * 
107      * @param listener
108      *            the listener that will receive ReportChangeEvents.
109      */
110     void addReportChangeListener(ReportChangeListener listener);
111 
112     /***
113      * Removes a listener from the list.
114      * 
115      * @param listener
116      *            the listener to remove from the list of listeners on this
117      *            report.
118      */
119     void removeReportChangeListener(ReportChangeListener listener);
120 
121     /***
122      * This method enables to clear the report lines.
123      */
124     void clear();
125 
126     /***
127      * This methods returns a filter to apply to this report. It is not defined
128      * whether this filter must be applied outside the report when data is added
129      * or if the report uses the filter directly.
130      * 
131      * @return the filter currently applied to that report.
132      */
133     ReportFilter getFilter();
134 
135     /***
136      * This method enables to change the filter that applies to this report.
137      * 
138      * @param filter
139      *            the new filter to use on this report.
140      */
141     void setFilter(ReportFilter filter);
142 
143     /***
144      * This method enables to access the class of the objects returned by the
145      * getValueAt for this column. This method reflects the TableModel method.
146      * 
147      * @param columnIndex
148      *            the index of the queried column.
149      * @return the class of the objects in a particular column. Objects can
150      *         actually be of a subclass of the returned class.
151      */
152     Class getColumnClass(int columnIndex);
153 }