com.ricebridge.xmlman
Class RecordListenerSupport

java.lang.Object
  extended bycom.ricebridge.xmlman.RecordListenerSupport
All Implemented Interfaces:
RecordListener
Direct Known Subclasses:
BadRecordsTest.FailingRecordListener, BeanRecordListener, CallSequenceTest.SequenceRecordListener, LoadRecordListenerTest.SimpleRecordListener, ResultSetRecordListener, StringArrayRecordListener, StringListRecordListener, TableModelRecordListener

public abstract class RecordListenerSupport
extends Object
implements RecordListener

Helper class for implementing the RecordListener interface.

Use of this class will help ensure future compatibility with any XML Manager API changes. Subclasses should implement the *Impl methods (for example, handleRecordImpl) rather than the declared interface methods such as handleRecord. See the RecordListener interface documentation for a description of the calling sequence of the methods in this class.

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


Field Summary
protected  String[] iFieldNames
          Record specification field names, if specified in the RecordSpec object associated with this RecordListener.
 
Constructor Summary
RecordListenerSupport()
           
 
Method Summary
 void endProcess()
          Helper implementation of RecordListener.endProcess.
protected  void endProcessImpl()
          Implement this method to receive notification that the saving of XML data has ended.
 BadRecord handleRecord(String[] pRecord, long pRecordNumber)
          Helper implementation of RecordListener.handleRecord.
protected abstract  BadRecord handleRecordImpl(String[] pRecord, long pRecordNumber)
          Implement this method to receive record data as it parsed.
 void setFieldNames(String[] pFieldNames)
          Helper implementation of RecordListener.setFieldNames.
protected  void setFieldNamesImpl(String[] pFieldNames)
          Implement this method to obtain the record specification field names, if available.
 void setXmlSpec(XmlSpec pXmlSpec)
          Helper implementation of RecordListener.setXmlSpec.
protected  void setXmlSpecImpl(XmlSpec pXmlSpec)
          Implement this method to receive the current XmlSpec settings.
 void startProcess()
          Helper implementation of RecordListener.startProcess.
protected  void startProcessImpl()
          Implement this method to receive notification that the saving of XML data is about to start.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iFieldNames

protected String[] iFieldNames
Record specification field names, if specified in the RecordSpec object associated with this RecordListener. NOTE: may be empty.

Constructor Detail

RecordListenerSupport

public RecordListenerSupport()
Method Detail

setXmlSpec

public void setXmlSpec(XmlSpec pXmlSpec)
Helper implementation of RecordListener.setXmlSpec. Subclasses should implement setXmlSpecImpl.

Specified by:
setXmlSpec in interface RecordListener
Parameters:
pXmlSpec - XmlSpec object

setFieldNames

public void setFieldNames(String[] pFieldNames)
Helper implementation of RecordListener.setFieldNames. Subclasses should implement setFieldNamesImpl.

Specified by:
setFieldNames in interface RecordListener
Parameters:
pFieldNames - String[] of field names

startProcess

public void startProcess()
Helper implementation of RecordListener.startProcess. Subclasses should implement startProcessImpl.

Specified by:
startProcess in interface RecordListener

handleRecord

public BadRecord handleRecord(String[] pRecord,
                              long pRecordNumber)
Helper implementation of RecordListener.handleRecord. Subclasses should implement handleRecordImpl.

Specified by:
handleRecord in interface RecordListener
Parameters:
pRecord - record data as a String[]
pRecordNumber - current count of records
Returns:
BadRecord if there was a problem, null otherwise

endProcess

public void endProcess()
Helper implementation of RecordListener.endProcess. Subclasses should implement endProcessImpl.

Specified by:
endProcess in interface RecordListener

setXmlSpecImpl

protected void setXmlSpecImpl(XmlSpec pXmlSpec)
                       throws Exception
Implement this method to receive the current XmlSpec settings.

This method is optional for subclasses, as an empty implementation is provided here.

Parameters:
pXmlSpec - XML specification
Throws:
Exception
See Also:
setXmlSpec(com.ricebridge.xmlman.XmlSpec), RecordListener.setXmlSpec(com.ricebridge.xmlman.XmlSpec)

setFieldNamesImpl

protected void setFieldNamesImpl(String[] pFieldNames)
                          throws Exception
Implement this method to obtain the record specification field names, if available.

The default implementation stores the field names in the iFieldNames member variable. This method is optional for subclasses, as an implementation is provided here.

Parameters:
pFieldNames - data record field names
Throws:
Exception
See Also:
setFieldNames(java.lang.String[]), RecordListener.setFieldNames(java.lang.String[])

startProcessImpl

protected void startProcessImpl()
                         throws Exception
Implement this method to receive notification that the saving of XML data is about to start.

This method is optional for subclasses, as an empty implementation is provided here.

Throws:
Exception
See Also:
startProcess(), RecordListener.startProcess()

handleRecordImpl

protected abstract BadRecord handleRecordImpl(String[] pRecord,
                                              long pRecordNumber)
                                       throws Exception
Implement this method to receive record data as it parsed.

The record number is specific to each RecordSpec. This method must be implemented by subclasses.

Parameters:
pRecord - record data as a String[]
pRecordNumber - current count of records
Throws:
Exception
See Also:
handleRecord(java.lang.String[], long), RecordListener.handleRecord(java.lang.String[], long)

endProcessImpl

protected void endProcessImpl()
                       throws Exception
Implement this method to receive notification that the saving of XML data has ended.

This method is optional for subclasses, as an empty implementation is provided here.

Throws:
Exception
See Also:
endProcess(), RecordListener.endProcess()


Copyright © 2004-2005 Ricebridge