public interface JRDataSourceProvider
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
}
}
Modifier and Type | Method and Description |
---|---|
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. |
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, 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.UnsupportedOperationException
- is the method is not supportedJRException
- 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 disposeJRException
- if the data source could not be disposedCopyright © 2019 TIBCO Software Inc.. All rights reserved.