public class JRCsvDataSourceProvider extends Object implements JRDataSourceProvider
Modifier and Type | Field and Description |
---|---|
static String |
EXCEPTION_MESSAGE_KEY_CANNOT_FIND_SOURCE |
Constructor and Description |
---|
JRCsvDataSourceProvider(File file)
Builds a datasource instance.
|
JRCsvDataSourceProvider(InputStream stream) |
JRCsvDataSourceProvider(Reader reader)
Builds a datasource instance.
|
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. |
String[] |
getColumnNames() |
DateFormat |
getDateFormat() |
char |
getFieldDelimiter() |
JRField[] |
getFields(JasperReport report)
Returns the fields that are available from the data source.
|
NumberFormat |
getNumberFormat() |
String |
getRecordDelimiter() |
void |
setColumnNames(String[] colNames) |
void |
setDateFormat(DateFormat dateFormat) |
void |
setFieldDelimiter(char fieldDelimiter) |
void |
setNumberFormat(NumberFormat numberFormat) |
void |
setRecordDelimiter(String recordDelimiter) |
boolean |
supportsGetFieldsOperation()
Returns true if the provider supports the
getFields
operation. |
public static final String EXCEPTION_MESSAGE_KEY_CANNOT_FIND_SOURCE
public JRCsvDataSourceProvider(InputStream stream)
stream
- an input stream containing CSV datapublic JRCsvDataSourceProvider(File file) throws FileNotFoundException
file
- a file containing CSV dataFileNotFoundException
public JRCsvDataSourceProvider(Reader reader)
reader
- a Reader instance, for reading the streampublic boolean supportsGetFieldsOperation()
JRDataSourceProvider
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.supportsGetFieldsOperation
in interface JRDataSourceProvider
public JRField[] getFields(JasperReport report) throws JRException, UnsupportedOperationException
JRDataSourceProvider
getFields
in interface JRDataSourceProvider
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.JRException
- if an error occurs.UnsupportedOperationException
- is the method is not supportedpublic JRDataSource create(JasperReport report) throws JRException
JRDataSourceProvider
create
in interface JRDataSourceProvider
report
- the report that will be filled using the created data source.JRException
- if the data source creation has failedpublic void dispose(JRDataSource dataSource) throws JRException
JRDataSourceProvider
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.dispose
in interface JRDataSourceProvider
dataSource
- the data source to disposeJRException
- if the data source could not be disposedpublic String[] getColumnNames()
public void setColumnNames(String[] colNames)
public DateFormat getDateFormat()
public void setDateFormat(DateFormat dateFormat)
public char getFieldDelimiter()
public void setFieldDelimiter(char fieldDelimiter)
public String getRecordDelimiter()
public void setRecordDelimiter(String recordDelimiter)
public NumberFormat getNumberFormat()
public void setNumberFormat(NumberFormat numberFormat)
Copyright © 2021 TIBCO Software Inc.. All rights reserved.