|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface JRDataSourceProvider
Abstracts the means of creating and disposing a data source.
This interface is meant to be the standard way to plug custom
data sources into GUI designers. Typically the report developer will
implement this interface to create and return a configured data source
of the desired type and then configure the designer to use this implementation.
The following example demonstrates a provider for a
JRBeanCollectionDataSource
.
public class MyBeansDataSource extends JRAbstractBeanDataSourceProvider {
public MyBeansDataSource() {
super(PersonBean.class);
}
public JRDataSource create(JasperReport report) throws JRException {
ArrayList list = new ArrayList();
list.add(new PersonBean("Teodor"));
list.add(new PersonBean("Peter"));
return new JRBeanCollectionDataSource(list);
}
public void dispose(JRDataSource dataSource) throws JRException {
// nothing to dispose
}
}
Method Summary | |
---|---|
JRDataSource |
create(JasperReport report)
Creates and returns a new instance of the provided data source. |
void |
dispose(JRDataSource dataSource)
Disposes the data source previously obtained using the create method. |
JRField[] |
getFields(JasperReport report)
Returns the fields that are available from the data source. |
boolean |
supportsGetFieldsOperation()
Returns true if the provider supports the getFields
operation. |
Method Detail |
---|
boolean supportsGetFieldsOperation()
getFields
operation. By returning true in this method the data source provider indicates
that it is able to introspect the data source and discover the available fields.
JRField[] getFields(JasperReport report) throws JRException, java.lang.UnsupportedOperationException
report
- the report that will be filled using the data source created by this provider.
The passed in report can be null. That means that no compiled report is available yet.
java.lang.UnsupportedOperationException
- is the method is not supported
JRException
- if an error occurs.JRDataSource create(JasperReport report) throws JRException
report
- the report that will be filled using the created data source.
JRException
- if the data source creation has failedvoid dispose(JRDataSource dataSource) throws JRException
create
method.
This method must close any resources associated with the
data source. For instance the database connection should be
closed in case of the
JRResultSetDataSource
.
JRResultSetDataSource
a subclass of this data source can be created. This subclass will
hold the database connection and the prepared statement that were
used to obtain the ResultSet. On the time of the dispose these resources
can be retrieved from the data source object and closed.
dataSource
- the data source to dispose
JRException
- if the data source could not be disposed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |