|
|||||||||||
| 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.TableModelLineProvider
An implementation of LineProvider that provides data lines for saving
from a TableModel object.
The easiest way to save your CSV data using this format is to use the
CsvManager.saveTableModel method.
You can get a TableModel from a JTable using the
JTable.getModel method.
TableModelLineProvider is designed to be subclassed. You can change
the default implementation by calling the
CsvManagerStore.setTableModelLineProviderClass
method, and providing a subclass of
TableModelLineProvider. 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,
ResultSetLineProvider,
BeanLineProvider| Field Summary | |
static boolean |
DEFAULT_TableModel_saveHeaders
Default value of TableModel.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 long |
iLineIndex
Current line. |
protected boolean |
iSaveHeaders
Save the column headers to the CSV file. |
protected TableModel |
iTableModel
The TableModel that the data comes from. |
static String |
PROP_TableModel_saveHeaders
Save the TableModel column names as the first line of the CSV file. |
| Constructor Summary | |
TableModelLineProvider()
Create uninitialised for use with setTableModel(javax.swing.table.TableModel, boolean). |
|
TableModelLineProvider(TableModel pTableModel,
boolean pSaveHeaders)
Create initialised. |
|
| Method Summary | |
boolean |
hasNextLineImpl()
Return true if TableModel contains more rows. |
String[] |
nextLineImpl()
Return the current row of the TableModel as a String[] array. |
protected void |
setCsvSpecImpl(CsvSpec pCsvSpec)
Handle property settings for loading data from a TableModel. |
void |
setTableModel(TableModel pTableModel,
boolean pSaveHeaders)
Set the TableModel providing data to save. |
void |
startProcessImpl()
Start the saving process. |
| Methods inherited from class com.ricebridge.csvman.CustomLineProvider |
endProcessImpl, 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_TableModel_saveHeaders
TableModel column names as the first line of the CSV file.
(name for CsvSpec.setProperty: TableModel.saveHeaders).
public static final boolean DEFAULT_TableModel_saveHeaders
TableModel.saveHeaders (false).
protected boolean iSaveHeaders
protected TableModel iTableModel
TableModel that the data comes from.
protected String[] iHeaders
protected boolean iFirstLine
protected int iFieldCount
protected long iLineIndex
| Constructor Detail |
public TableModelLineProvider()
setTableModel(javax.swing.table.TableModel, boolean).
public TableModelLineProvider(TableModel pTableModel,
boolean pSaveHeaders)
setTableModel(javax.swing.table.TableModel, boolean) for details.
pTableModel - TableModel providing datapSaveHeaders - Save the TableModel headers as first line| Method Detail |
protected void setCsvSpecImpl(CsvSpec pCsvSpec)
throws Exception
TableModel.
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, TableModel, 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_TableModel_saveHeaders.
setCsvSpecImpl in class CustomLineProviderpCsvSpec - CsvSpec object
ExceptionLineProvider.setCsvSpec(com.ricebridge.csvman.CsvSpec),
PROP_TableModel_saveHeaders
public void startProcessImpl()
throws Exception
startProcessImpl in class CustomLineProviderExceptionLineProvider.startProcess()
public boolean hasNextLineImpl()
throws Exception
true if TableModel contains more rows.
hasNextLineImpl in class CustomLineProviderExceptionLineProvider.hasNextLine,
nextLineImpl
public String[] nextLineImpl()
throws Exception
TableModel as a String[] array.
nextLineImpl in class CustomLineProviderExceptionLineProvider.nextLine,
hasNextLineImpl
public void setTableModel(TableModel pTableModel,
boolean pSaveHeaders)
TableModel providing data to save.
The default number of fields per line is taken from
TableModel.getColumnCount
and the headers (output as the first line when PROP_TableModel_saveHeaders is true),
are taken from TableModel.getColumnName.
pTableModel - TableModel providing datapSaveHeaders - Save the TableModel headers as first line
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||