com.ricebridge.xmlman
Class ResultSetRecordProvider

java.lang.Object
  extended bycom.ricebridge.xmlman.RecordProviderSupport
      extended bycom.ricebridge.xmlman.ResultSetRecordProvider
All Implemented Interfaces:
RecordProvider

public class ResultSetRecordProvider
extends RecordProviderSupport

An implementation of RecordProvider that provides data records for saving from a ResultSet object.

This class is used to implement the saveResultSet(*,RecordSpec,ResultSet) methods in XmlManager. It simply reads the next data record from the specified ResultSet, maintaining an internal index of the current record.

ResultSetRecordProvider is designed to be subclassed. You can change the default implementation by calling the setResultSetRecordProviderClass method of XmlManagerStore, and providing a subclass of ResultSetRecordProvider. XmlManagerStore can be accessed using XmlManager.getXmlManagerStore().

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


Field Summary
protected  int iFieldCount
          Number of data fields in record, determined by ResultSetMetaData.
protected  boolean iFirstRecord
          Indicate that internal state is at the first record.
protected  String[] iHeaders
          Column names.
protected  boolean iResetBeforeFirst
          Reset ResultSet to beginning after saving data.
protected  ResultSet iResultSet
          ResultSet containing source data.
protected  int iResultSetType
          Type of ResultSet, determines if it can be reset.
protected  boolean iSaveHeaders
          Save the column names as first data record.
static String PROP_ResultSet_resetBeforeFirst
          Reset ResultSet after saving (name for XmlSpec.setProperty: ResultSet.resetBeforeFirst).
static String PROP_ResultSet_saveHeaders
          Output headers as first data record (name for XmlSpec.setProperty: ResultSet.saveHeaders).
 
Fields inherited from class com.ricebridge.xmlman.RecordProviderSupport
iFieldNames
 
Constructor Summary
ResultSetRecordProvider()
          Create uninitialised for use with setResultSet(java.sql.ResultSet).
ResultSetRecordProvider(ResultSet pResultSet)
          Create initialised.
 
Method Summary
protected  void endProcessImpl()
          Reset ResultSet by calling the beforeFirst method if PROP_ResultSet_resetBeforeFirst option is true and ResultSet type supports it.
protected  boolean hasNextRecordImpl()
          Check if there are any more records.
protected  String[] nextRecordImpl()
          Return next data record as a String[] array.
 void setResultSet(ResultSet pResultSet)
          Set the ResultSet providing data to save.
protected  void setXmlSpecImpl(XmlSpec pXmlSpec)
          Handle property settings for saving ResultSets.
protected  void startProcessImpl()
          Start the saving process.
 
Methods inherited from class com.ricebridge.xmlman.RecordProviderSupport
endProcess, hasNextRecord, nextRecord, setFieldNames, setFieldNamesImpl, setXmlSpec, startProcess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_ResultSet_saveHeaders

public static final String PROP_ResultSet_saveHeaders
Output headers as first data record (name for XmlSpec.setProperty: ResultSet.saveHeaders).

See Also:
Constant Field Values

PROP_ResultSet_resetBeforeFirst

public static final String PROP_ResultSet_resetBeforeFirst
Reset ResultSet after saving (name for XmlSpec.setProperty: ResultSet.resetBeforeFirst).

See Also:
Constant Field Values

iResultSet

protected ResultSet iResultSet
ResultSet containing source data.


iSaveHeaders

protected boolean iSaveHeaders
Save the column names as first data record. See setXmlSpecImpl.


iHeaders

protected String[] iHeaders
Column names.


iFirstRecord

protected boolean iFirstRecord
Indicate that internal state is at the first record.


iFieldCount

protected int iFieldCount
Number of data fields in record, determined by ResultSetMetaData.


iResultSetType

protected int iResultSetType
Type of ResultSet, determines if it can be reset.


iResetBeforeFirst

protected boolean iResetBeforeFirst
Reset ResultSet to beginning after saving data.

Constructor Detail

ResultSetRecordProvider

public ResultSetRecordProvider()
Create uninitialised for use with setResultSet(java.sql.ResultSet).


ResultSetRecordProvider

public ResultSetRecordProvider(ResultSet pResultSet)
Create initialised. See setResultSet for details.

Parameters:
pResultSet - ResultSet providing data
Method Detail

setResultSet

public void setResultSet(ResultSet pResultSet)
Set the ResultSet providing data to save.

The default number of fields per record is taken from ResultSetMetaData.getColumnCount() and the headers (output as the first record when the property ResultSet.saveHeaders is true), are taken from ResultSetMetaData.getColumnName(int).

Parameters:
pResultSet - ResultSet providing data

setXmlSpecImpl

protected void setXmlSpecImpl(XmlSpec pXmlSpec)
Handle property settings for saving ResultSets.

You can change these using XmlSpec.

Overrides:
setXmlSpecImpl in class RecordProviderSupport
Parameters:
pXmlSpec - XML specification
See Also:
RecordListener.setXmlSpec(com.ricebridge.xmlman.XmlSpec), PROP_ResultSet_saveHeaders, PROP_ResultSet_resetBeforeFirst

startProcessImpl

protected void startProcessImpl()
Start the saving process.

Overrides:
startProcessImpl in class RecordProviderSupport
See Also:
RecordProviderSupport.startProcess(), RecordProvider.startProcess()

hasNextRecordImpl

protected boolean hasNextRecordImpl()
Check if there are any more records.

Specified by:
hasNextRecordImpl in class RecordProviderSupport
See Also:
RecordProviderSupport.hasNextRecord(), RecordProvider.hasNextRecord()

nextRecordImpl

protected String[] nextRecordImpl()
Return next data record as a String[] array.

Specified by:
nextRecordImpl in class RecordProviderSupport
See Also:
RecordProviderSupport.nextRecord(), RecordProvider.nextRecord()

endProcessImpl

protected void endProcessImpl()
Reset ResultSet by calling the beforeFirst method if PROP_ResultSet_resetBeforeFirst option is true and ResultSet type supports it.

Overrides:
endProcessImpl in class RecordProviderSupport
See Also:
RecordProviderSupport.endProcess(), RecordProvider.endProcess()


Copyright © 2004-2005 Ricebridge