| java.lang.Object net.sf.jasperreports.engine.data.JRCsvDataSource
JRCsvDataSource | public class JRCsvDataSource implements JRDataSource(Code) | | This datasource implementation reads a CSV stream. Datasource rows are separated by a record delimiter string and
fields inside a row are separated by a field delimiter character. Fields containing delimiter characters can be
placed inside quotes. If fields contain quotes themselves, these are duplicated (example: "John ""Doe""" will be
displayed as John "Doe").
Since CSV does not specify column names, the default naming convention is to name report fields COLUMN_x and map each
column with the field found at index x in each row (these indices start with 0). To avoid this situation, users can
either specify a collection of column names or set a flag to read the column names from the first row of the CSV file.
author: Ionut Nedelcu (ionutned@users.sourceforge.net) version: $Id: JRCsvDataSource.java 1529 2006-12-21 14:05:08Z teodord $ |
Constructor Summary | |
public | JRCsvDataSource(InputStream stream) Creates a datasource instance from a CSV data input stream, using the default encoding. | public | JRCsvDataSource(InputStream stream, String charsetName) Creates a datasource instance from a CSV data input stream, using the specified encoding. | public | JRCsvDataSource(File file) Creates a datasource instance from a CSV file, using the default encoding. | public | JRCsvDataSource(File file, String charsetName) Creates a datasource instance from a CSV file, using the specified encoding. | public | JRCsvDataSource(Reader reader) Creates a datasource instance from a CSV data reader. |
JRCsvDataSource | public JRCsvDataSource(InputStream stream)(Code) | | Creates a datasource instance from a CSV data input stream, using the default encoding.
Parameters: stream - an input stream containing CSV data |
JRCsvDataSource | public JRCsvDataSource(InputStream stream, String charsetName) throws UnsupportedEncodingException(Code) | | Creates a datasource instance from a CSV data input stream, using the specified encoding.
Parameters: stream - an input stream containing CSV data Parameters: charsetName - the encoding to use |
JRCsvDataSource | public JRCsvDataSource(File file) throws FileNotFoundException(Code) | | Creates a datasource instance from a CSV file, using the default encoding.
Parameters: file - a file containing CSV data |
JRCsvDataSource | public JRCsvDataSource(Reader reader)(Code) | | Creates a datasource instance from a CSV data reader.
Parameters: reader - a Reader instance, for reading the stream |
close | public void close()(Code) | | Closes the reader. Users of this data source should close it after usage.
|
getDateFormat | public DateFormat getDateFormat()(Code) | | Gets the date format that will be used to parse date fields
|
getFieldDelimiter | public char getFieldDelimiter()(Code) | | Returns the field delimiter character.
|
getRecordDelimiter | public String getRecordDelimiter()(Code) | | Returns the record delimiter string.
|
setColumnNames | public void setColumnNames(String[] columnNames)(Code) | | Specifies an array of strings representing column names matching field names in the report template
|
setDateFormat | public void setDateFormat(DateFormat dateFormat)(Code) | | Sets the desired date format to be used for parsing date fields
|
setFieldDelimiter | public void setFieldDelimiter(char fieldDelimiter)(Code) | | Sets the field delimiter character. The default is comma. If characters such as comma or quotes are specified,
the results can be unpredictable.
Parameters: fieldDelimiter - |
setRecordDelimiter | public void setRecordDelimiter(String recordDelimiter)(Code) | | Sets the record delimiter string. The default is line feed (\n).
Parameters: recordDelimiter - |
setUseFirstRowAsHeader | public void setUseFirstRowAsHeader(boolean useFirstRowAsHeader)(Code) | | Specifies whether the first line of the CSV file should be considered a table
header, containing column names matching field names in the report template
|
|
|