com.ricebridge.csvman
Class BasicLineListener

java.lang.Object
  extended bycom.ricebridge.csvman.LineListenerSupportImpl
      extended bycom.ricebridge.csvman.CustomLineListener
          extended bycom.ricebridge.csvman.BasicLineListener
All Implemented Interfaces:
LineListener
Direct Known Subclasses:
AsListsLineListener

public class BasicLineListener
extends CustomLineListener

Simple implementation of LineListener that stores loaded data lines as a List of String[] arrays.

The easiest way to get your CSV data in this format is to use the CsvManager.load method.

This LineListener is a good one to use as a template for your own custom LineListeners.

BasicLineListener is designed to be subclassed. You can change the default implementation by calling the CsvManagerStore.setBasicLineListenerClass method, and providing a subclass of BasicLineListener. CsvManagerStore can be accessed using CsvManager.getCsvManagerStore().

The Source Code of this Java class is available under a BSD-style license.

See Also:
LineListener, CustomLineListener, ResultSetLineListener, AsListsLineListener, TableModelLineListener, BeanLineListener

Field Summary
protected  ArrayList iData
          List of String[] arrays holding data lines.
 
Constructor Summary
BasicLineListener()
           
 
Method Summary
protected  void endProcessImpl()
          Handle end of loading process.
 List getData()
          Get the list of loaded data lines as a List of String[] arrays.
protected  BadLine handleLineImpl(String[] pLine, int pNumFields, long pLineNumber, String pOriginalLine)
          Handle each data line by storing it in a list.
protected  void startProcessImpl()
          Handle start of loading process by creating empty list for data lines.
 
Methods inherited from class com.ricebridge.csvman.CustomLineListener
handleBadLineImpl, setCsvSpecImpl, 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

iData

protected ArrayList iData
List of String[] arrays holding data lines.

Constructor Detail

BasicLineListener

public BasicLineListener()
Method Detail

startProcessImpl

protected void startProcessImpl()
                         throws Exception
Handle start of loading process by creating empty list for data lines.

Overrides:
startProcessImpl in class CustomLineListener
Throws:
Exception
See Also:
endProcessImpl

endProcessImpl

protected void endProcessImpl()
                       throws Exception
Handle end of loading process.

Overrides:
endProcessImpl in class CustomLineListener
Throws:
Exception
See Also:
startProcessImpl

handleLineImpl

protected BadLine handleLineImpl(String[] pLine,
                                 int pNumFields,
                                 long pLineNumber,
                                 String pOriginalLine)
                          throws Exception
Handle each data line by storing it in a list.

Specified by:
handleLineImpl in class CustomLineListener
Parameters:
pLine - String values of data fields in line
pNumFields - Number of data fields actually found on the current line
pLineNumber - Count of lines processed so far.
pOriginalLine - Text of original data line from data source
Returns:
null if line is OK, BadLine object if line was bad in some way
Throws:
Exception
See Also:
LineListener.handleLine, BadLine, handleBadLineImpl

getData

public List getData()
Get the list of loaded data lines as a List of String[] arrays.



Copyright © 2003-2006 Ricebridge