com.ricebridge.xmlman
Class BeanRecordProvider

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

public class BeanRecordProvider
extends RecordProviderSupport

Simple implementation of RecordProvider that provides data records for saving a List of Java Beans.

This class is used to implement the saveBeans(*,RecordSpec,BeanSpec) methods in XmlManager. Data records are created from Java Bean objects by calling the property get methods of the objects in accordance with the Java Beans specification. Ordinary, boolean and indexed properties are supported. See the BeanSpec documentation for more information.

BeanRecordProvider is designed to be subclassed. You can change the default implementation by calling the setBeanRecordProviderClass method of XmlManagerStore, and providing a subclass of BeanRecordProvider. 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 iBeanIndex
          Index of current bean in List.
protected  List iBeans
          List of Beans.
protected  BeanSpec iBeanSpec
          BeanSpec specification object defining the properties of the beans to save.
protected  boolean iUseDefault
          If a data field is invalid, use the default value of the property for that field data type.
static String PROP_Bean_useDefault
          Specify that invalid data fields have the default value for their data type (name for XmlSpec.setProperty: Bean.useDefault).
 
Fields inherited from class com.ricebridge.xmlman.RecordProviderSupport
iFieldNames
 
Constructor Summary
BeanRecordProvider()
          Create uninitialised for use with setBeans(java.util.List).
BeanRecordProvider(List pData)
          Create using a List of Java Beans to save.
 
Method Summary
 boolean hasNextRecordImpl()
          Check if there are any beans left.
 String[] nextRecordImpl()
          Return data fields of next bean as a String[] array.
 void setBeans(List pBeans)
          Set the Java Beans to save.
 void setBeanSpec(BeanSpec pBeanSpec)
          Set the BeanSpec object that defines the beans to save.
protected  void setXmlSpecImpl(XmlSpec pXmlSpec)
          Handle property settings for saving Java Beans.
 void startProcessImpl()
          Start the load process.
 
Methods inherited from class com.ricebridge.xmlman.RecordProviderSupport
endProcess, endProcessImpl, 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_Bean_useDefault

public static final String PROP_Bean_useDefault
Specify that invalid data fields have the default value for their data type (name for XmlSpec.setProperty: Bean.useDefault).

See Also:
Constant Field Values

iBeans

protected List iBeans
List of Beans.


iBeanIndex

protected int iBeanIndex
Index of current bean in List.


iBeanSpec

protected BeanSpec iBeanSpec
BeanSpec specification object defining the properties of the beans to save.


iUseDefault

protected boolean iUseDefault
If a data field is invalid, use the default value of the property for that field data type.

Constructor Detail

BeanRecordProvider

public BeanRecordProvider()
Create uninitialised for use with setBeans(java.util.List).


BeanRecordProvider

public BeanRecordProvider(List pData)
Create using a List of Java Beans to save.

Method Detail

setBeans

public void setBeans(List pBeans)
Set the Java Beans to save.


setBeanSpec

public void setBeanSpec(BeanSpec pBeanSpec)
Set the BeanSpec object that defines the beans to save.

The BeanSpec object contains the definitions of the bean properties and performs the conversion from internal Java data types to String values.

Parameters:
pBeanSpec - BeanSpec definition of beans to save

setXmlSpecImpl

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

You can change these using XmlSpec.

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

startProcessImpl

public void startProcessImpl()
Start the load process.

Performs some sanity checks on the saving setup.

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

hasNextRecordImpl

public boolean hasNextRecordImpl()
Check if there are any beans left.

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

nextRecordImpl

public String[] nextRecordImpl()
Return data fields of next bean as a String[] array.

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


Copyright © 2004-2005 Ricebridge