|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.ricebridge.csvman.LineProviderSupportImpl
com.ricebridge.csvman.CustomLineProvider
com.ricebridge.csvman.ResultSetLineProvider
An implementation of LineProvider that provides data lines for saving
from a ResultSet object.
The easiest way to save your CSV data using this format is to use the
CsvManager.saveResultSet method.
ResultSetLineProvider is designed to be subclassed. You can change
the default implementation by calling the
CsvManagerStore.setResultSetLineProviderClass
method, and providing a subclass of
ResultSetLineProvider. CsvManagerStore can be accessed
using CsvManager.getCsvManagerStore().
The Source Code of this Java class is available under a BSD-style license.
LineProvider,
CustomLineProvider,
BasicLineProvider,
AsListsLineProvider,
TableModelLineProvider,
BeanLineProvider| Field Summary | |
static boolean |
DEFAULT_ResultSet_saveHeaders
Default value of ResultSet.saveHeaders (false). |
protected int |
iFieldCount
Number of data fields per line. |
protected boolean |
iFirstLine
Flag to indicate processing of the first line. |
protected String[] |
iHeaders
The column headers |
protected ResultSet |
iResultSet
The ResultSet that the data comes from. |
protected boolean |
iSaveHeaders
Save the column headers to the CSV file. |
static String |
PROP_ResultSet_saveHeaders
Save the ResultSet column names as the first line of the CSV file. |
| Constructor Summary | |
ResultSetLineProvider()
Create uninitialised for use with setResultSet(java.sql.ResultSet, boolean). |
|
| Method Summary | |
protected void |
endProcessImpl()
End the saving process. |
protected String |
getFieldAsString(int pFieldIndex)
Get the String value of a ResultSet field. |
protected boolean |
hasNextLineImpl()
Return true if ResultSet.next returns true. |
protected String[] |
nextLineImpl()
Return current ResultSet row as a String[] array. |
protected void |
setCsvSpecImpl(CsvSpec pCsvSpec)
Handle property settings for loading data from a ResultSet. |
void |
setResultSet(ResultSet pResultSet,
boolean pSaveHeaders)
Set the ResultSet that provides the data to save. |
protected void |
startProcessImpl()
Start the saving process. |
| Methods inherited from class com.ricebridge.csvman.CustomLineProvider |
setLineSpecImpl |
| Methods inherited from class com.ricebridge.csvman.LineProviderSupportImpl |
endProcess, hasNextLine, nextLine, setCsvSpec, setLineSpec, startProcess |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String PROP_ResultSet_saveHeaders
ResultSet column names as the first line of the CSV file.
(name for CsvSpec.setProperty: ResultSet.saveHeaders).
public static final boolean DEFAULT_ResultSet_saveHeaders
ResultSet.saveHeaders (false).
protected boolean iSaveHeaders
protected ResultSet iResultSet
ResultSet that the data comes from.
protected String[] iHeaders
protected boolean iFirstLine
protected int iFieldCount
| Constructor Detail |
public ResultSetLineProvider()
setResultSet(java.sql.ResultSet, boolean).
| Method Detail |
protected void setCsvSpecImpl(CsvSpec pCsvSpec)
throws Exception
ResultSet.
You can change these using CsvSpec.
Compatibility note: the correct way to change the settings for a LineProvider is by using the
CsvSpec.setProperty method. CSV Manager 1.1 also allowed you to set certain
settings as save method parameters (for example: pHasHeaders
in CsvManager.save(File, ResultSet, boolean).
These parameters will be removed in CSV Manager 2.0, so you should not use them anymore.
They are only retained for compatibility with CSV Manager 1.1.
The property you can use here is: PROP_ResultSet_saveHeaders.
setCsvSpecImpl in class CustomLineProviderpCsvSpec - CsvSpec object
ExceptionLineProvider.setCsvSpec(com.ricebridge.csvman.CsvSpec),
PROP_ResultSet_saveHeaders
protected void startProcessImpl()
throws Exception
startProcessImpl in class CustomLineProviderExceptionLineProvider.startProcess()
protected boolean hasNextLineImpl()
throws Exception
true if ResultSet.next returns true.
hasNextLineImpl in class CustomLineProviderExceptionLineProvider.hasNextLine,
nextLineImpl
protected String[] nextLineImpl()
throws Exception
ResultSet row as a String[] array.
nextLineImpl in class CustomLineProviderExceptionLineProvider.nextLine,
hasNextLineImpl
protected void endProcessImpl()
throws Exception
endProcessImpl in class CustomLineProviderExceptionLineProvider.endProcess()
public void setResultSet(ResultSet pResultSet,
boolean pSaveHeaders)
ResultSet that provides the data to save.
The default number of fields per line is taken from
ResultSetMetaData.getColumnCount
and the headers (output as the first line when PROP_ResultSet_saveHeaders is true),
are taken from
ResultSetMetaData.getColumnName.
pResultSet - ResultSet providing datapSaveHeaders - Save the ResultSet headers as first line (old parameter, use PROP_ResultSet_saveHeaders instead)protected String getFieldAsString(int pFieldIndex)
String value of a ResultSet field.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||