|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.ricebridge.csvman.LineListenerSupportImpl
com.ricebridge.csvman.CustomLineListener
com.ricebridge.csvman.HeadersListenerSupport
com.ricebridge.csvman.ResultSetLineListener
An implementation of LineListener that inserts loaded data lines
into a ResultSet.
You can then use this ResultSet directly to retrieve the data. See CsvResultSet
for more details. The easiest way to get a ResultSet of your CSV data is to use the
CsvManager.loadResultSet method.
ResultSetLineListener is designed to be subclassed. You can change
the default implementation by calling the
CsvManagerStore.setResultSetLineListenerClass
method, and providing a subclass of
ResultSetLineListener. CsvManagerStore can be accessed
using CsvManager.getCsvManagerStore().
The Source Code of this Java class is available under a BSD-style license.
LineListener,
CustomLineListener,
BasicLineListener,
AsListsLineListener,
TableModelLineListener,
BeanLineListener| Field Summary | |
static boolean |
DEFAULT_ResultSet_dataHasHeaders
Default value of ResultSet.dataHasHeaders (false). |
protected Class |
iCsvResultSetClass
ResultSet implementation class used to create new instances. |
protected ArrayList |
iData
List of String[] arrays holding data lines. |
protected boolean |
iDataHasHeaders
When true, the first line of CSV data should be a header line specifying the data field names. |
protected int |
iNumFields
Number of data fields. |
static String |
PROP_ResultSet_dataHasHeaders
Specify that the first row of data is a header line containing the names of the data fields. |
| Fields inherited from class com.ricebridge.csvman.HeadersListenerSupport |
iHasHeaders |
| Constructor Summary | |
ResultSetLineListener()
|
|
| Method Summary | |
protected void |
endProcessImpl()
End the loading process. |
ResultSet |
getResultSet()
Get a ResultSet instance that presents the CSV data. |
protected BadLine |
handleLineImpl(String[] pLine,
int pNumFields,
long pLineNumber,
String pOriginalLine)
Add the data line String[] array to the list of ResultSet rows. |
void |
setCsvResultSetClass(Class pCsvResultSetClass)
Use your own subclass of CsvResultSet for loading CSV data. |
protected void |
setCsvSpecImpl(CsvSpec pCsvSpec)
Handle property settings for loading data in a ResultSet. |
protected void |
startProcessImpl()
Start the loading process. |
| Methods inherited from class com.ricebridge.csvman.HeadersListenerSupport |
getHasHeaders, setHasHeaders |
| Methods inherited from class com.ricebridge.csvman.CustomLineListener |
handleBadLineImpl, setLineSpecImpl |
| Methods inherited from class com.ricebridge.csvman.LineListenerSupportImpl |
endProcess, handleBadLine, handleLine, 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_dataHasHeaders
CsvSpec.setProperty: ResultSet.dataHasHeaders).
public static final boolean DEFAULT_ResultSet_dataHasHeaders
ResultSet.dataHasHeaders (false).
protected Class iCsvResultSetClass
ResultSet implementation class used to create new instances.
protected ArrayList iData
List of String[] arrays holding data lines.
protected int iNumFields
protected boolean iDataHasHeaders
true, the first line of CSV data should be a header line specifying the data field names.
| Constructor Detail |
public ResultSetLineListener()
| 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 LineListener is by using the
CsvSpec.setProperty method. CSV Manager 1.1 also allowed you to set certain
settings as load method parameters (for example: pHasHeaders
in CsvManager.loadResultSet(File, 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_dataHasHeaders.
setCsvSpecImpl in class CustomLineListenerpCsvSpec - CsvSpec object
ExceptionLineListener.setCsvSpec(com.ricebridge.csvman.CsvSpec),
PROP_ResultSet_dataHasHeaders
protected void startProcessImpl()
throws Exception
startProcessImpl in class CustomLineListenerExceptionLineListener.startProcess()
protected BadLine handleLineImpl(String[] pLine,
int pNumFields,
long pLineNumber,
String pOriginalLine)
throws Exception
String[] array to the list of ResultSet rows.
handleLineImpl in class CustomLineListenerpLine - String values of data fields in linepNumFields - Number of data fields actually found on the current linepLineNumber - Count of lines processed so far.pOriginalLine - Text of original data line from data source
null if line is OK, BadLine object if line was bad in some way
ExceptionLineListener.handleLine,
BadLine,
handleBadLineImpl
protected void endProcessImpl()
throws Exception
endProcessImpl in class CustomLineListenerExceptionLineListener.endProcess()public ResultSet getResultSet()
ResultSet instance that presents the CSV data.
public void setCsvResultSetClass(Class pCsvResultSetClass)
CsvResultSet for loading CSV data.
You may subclass CsvResultSet so that the CSV data is loaded into your own ResultSet.
You will need to provide an empty constructor so that the newInstance method will work. You
must also provide, via this method, the class of your ResultSet. Do this like so:
csvManager.getCsvManagerStore()
.getResultSetLineListener().setCsvResultSetClass( MyCsvResultSet.class );
If subclassing does not fit with your requirements, consider implementing your own variation of
CsvResultSet (source) and
ResultSetLineListener (source)
based on the source code provided as part of this API documentation.
NOTE: this method is deprecated. To provide your own version of CsvResultSet, please
subclass ResultSetLineListener directly and set the
iCsvResultSetClass member variable to your own
subclass of CsvResultSet.
pCsvResultSetClass - class of CsvResultSet subclassCsvResultSet
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||