com.ricebridge.csvman
Class MultiLineListener

java.lang.Object
  extended bycom.ricebridge.csvman.LineListenerSupportImpl
      extended bycom.ricebridge.csvman.CustomLineListener
          extended bycom.ricebridge.csvman.MultiLineListener
All Implemented Interfaces:
LineListener

public class MultiLineListener
extends CustomLineListener

Multiple LineListeners can receive data lines as they are loaded using this class.

If you need to send the data stream to multiple locations, use this class to register multiple LineListeners with the registerLineListener(com.ricebridge.csvman.LineListener) method. Then provide this class as the LineListener to CsvManager using the CsvManager.load(Object,LineListener) method.

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

See Also:
LineListener, CustomLineListener

Constructor Summary
MultiLineListener()
           
 
Method Summary
protected  void endProcessImpl()
          Calls LineListener.endProcess() on each registered LineListener in turn.
protected  void handleBadLineImpl(BadLine pBadLine)
          Calls LineListener.handleBadLine(com.ricebridge.csvman.BadLine) on each registered LineListener in turn.
protected  BadLine handleLineImpl(String[] pLine, int pNumFields, long pLineNumber, String pOriginalLine)
          Add data line to each registered LineListener.
 void registerLineListener(LineListener pLineListener)
          Register a LineListener.
protected  void setCsvSpecImpl(CsvSpec pCsvSpec)
          Pass CsvSpec to all registered LineListeners.
protected  void setLineSpecImpl(LineSpec pLineSpec)
          Pass LineSpec to all registered LineListeners.
protected  void startProcessImpl()
          Calls LineListener.startProcess() on each registered LineListener in turn.
 
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
 

Constructor Detail

MultiLineListener

public MultiLineListener()
Method Detail

setCsvSpecImpl

protected void setCsvSpecImpl(CsvSpec pCsvSpec)
Pass CsvSpec to all registered LineListeners.

Overrides:
setCsvSpecImpl in class CustomLineListener
Parameters:
pCsvSpec - CsvSpec for registered LineListeners.
See Also:
CsvSpec, setLineSpecImpl

setLineSpecImpl

protected void setLineSpecImpl(LineSpec pLineSpec)
Pass LineSpec to all registered LineListeners.

Overrides:
setLineSpecImpl in class CustomLineListener
Parameters:
pLineSpec - LineSpec for registered LineListeners.
See Also:
LineSpec, setCsvSpecImpl, BeanLineListener

startProcessImpl

protected void startProcessImpl()
Calls LineListener.startProcess() on each registered LineListener in turn.

Note: If an error occurs, no further calls are made and thus some registered LineListeners may not receive this method call. Future versions of CsvManager will resolve this issue.

Overrides:
startProcessImpl in class CustomLineListener
See Also:
LineListener.startProcess()

endProcessImpl

protected void endProcessImpl()
Calls LineListener.endProcess() on each registered LineListener in turn.

Note: If an error occurs, no further calls are made and thus some registered LineListeners may not receive this method call. Future versions of CsvManager will resolve this issue.

Overrides:
endProcessImpl in class CustomLineListener
See Also:
LineListener.endProcess()

handleLineImpl

protected BadLine handleLineImpl(String[] pLine,
                                 int pNumFields,
                                 long pLineNumber,
                                 String pOriginalLine)

Add data line to each registered LineListener.

If any LineListener returns a non-null BadLine, processing continues until all registered LineListeners have received the data line, and then the last non-null BadLine is returned. NOTE: if there is more than one BadLine then all except the last are lost. Future versions of CsvManager will add functionality to recover these BadLine objects.

Specified by:
handleLineImpl in class CustomLineListener
Parameters:
pLine - data line
pNumFields - number of data fields found
pLineNumber - line number index, counting from 1
pOriginalLine - original line of data
Returns:
null if line is OK, BadLine object if line was bad in some way
See Also:
LineListener.handleLine(java.lang.String[], int, long, java.lang.String)

handleBadLineImpl

protected void handleBadLineImpl(BadLine pBadLine)
Calls LineListener.handleBadLine(com.ricebridge.csvman.BadLine) on each registered LineListener in turn.

Note: If an error occurs, no further calls are made and thus some registered LineListeners may not receive this method call. Future versions of CsvManager will resolve this issue.

Overrides:
handleBadLineImpl in class CustomLineListener
Parameters:
pBadLine - BadLine object describing problem
See Also:
LineListener.handleBadLine(com.ricebridge.csvman.BadLine)

registerLineListener

public void registerLineListener(LineListener pLineListener)
Register a LineListener. This class calls the LineListenerSupportImpl.handleLine(java.lang.String[], int, long, java.lang.String) method of each registered LineListener in turn.

Parameters:
pLineListener - LineListener to register


Copyright © 2003-2006 Ricebridge