|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.ricebridge.csvman.LineProviderSupportImpl
com.ricebridge.csvman.CustomLineProvider
com.ricebridge.csvman.BeanLineProvider
Simple implementation of LineProvider that provides data records for saving
a List of Java Beans.
This class is used to implement the saveBeans(Object,LineSpec,BeanSpec,List)
methods in CsvManager.
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.
BeanLineProvider is designed to be subclassed. You can change the default implementation by calling the
setBeanLineProviderClass method of
CsvManagerStore, and providing a subclass of BeanLineProvider.
CsvManagerStore can be accessed using CsvManager.getCsvManagerStore().
The Source Code of this Java class is available under a BSD-style license.
| Field Summary | |
static boolean |
DEFAULT_Bean_saveHeaders
Default value of Bean.saveHeaders). |
static boolean |
DEFAULT_Bean_useDefault
Default value of Bean.useDefault). |
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 String[] |
iFieldNames
The names of the data fields, corresponding to the names of the Java Bean property methods. |
protected LineSpec |
iLineSpec
Description of the data fields. |
protected boolean |
iSaveHeaders
Output headers as first data line. |
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_saveHeaders
Output headers as first data line (name for CsvSpec.setProperty: Bean.saveHeaders). |
static String |
PROP_Bean_useDefault
Specify that invalid data fields have the default value for their data type (name for CsvSpec.setProperty: Bean.useDefault). |
| Constructor Summary | |
BeanLineProvider()
Create uninitialised for use with setBeans(java.util.List). |
|
BeanLineProvider(List pData)
Create using a List of Java Beans to save. |
|
| Method Summary | |
protected boolean |
hasNextLineImpl()
Check if there are any beans left. |
protected String[] |
nextLineImpl()
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 |
setCsvSpecImpl(CsvSpec pCsvSpec)
Handle property settings for saving Java Beans. |
protected void |
setLineSpecImpl(LineSpec pLineSpec)
Set the current LineSpec used for interpreting CSV data fields. |
protected void |
startProcessImpl()
Start the load process. |
| Methods inherited from class com.ricebridge.csvman.CustomLineProvider |
endProcessImpl |
| Methods inherited from class com.ricebridge.csvman.LineProviderSupportImpl |
endProcess, hasNextLine, nextLine, setCsvSpec, setLineSpec, startProcess |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String PROP_Bean_useDefault
CsvSpec.setProperty: Bean.useDefault).
public static final boolean DEFAULT_Bean_useDefault
Bean.useDefault).
public static final String PROP_Bean_saveHeaders
CsvSpec.setProperty: Bean.saveHeaders).
public static final boolean DEFAULT_Bean_saveHeaders
Bean.saveHeaders).
protected List iBeans
List of Beans.
protected int iBeanIndex
List.
protected BeanSpec iBeanSpec
BeanSpec specification object defining the properties of the beans to save.
protected boolean iUseDefault
protected boolean iSaveHeaders
protected LineSpec iLineSpec
protected String[] iFieldNames
| Constructor Detail |
public BeanLineProvider()
setBeans(java.util.List).
public BeanLineProvider(List pData)
List of Java Beans to save.
| Method Detail |
public void setBeans(List pBeans)
public void setBeanSpec(BeanSpec pBeanSpec)
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.
pBeanSpec - BeanSpec definition of beans to save
protected void setLineSpecImpl(LineSpec pLineSpec)
throws Exception
CustomLineProviderLineSpec used for interpreting CSV data fields.
You can implement this method when you extend CustomLineProvider,
but it is not required.
The LineSpec controls the conversion of internal data into individual CSV data fields.
Whereas CsvSpec controls the entire process, LineSpec only applies to each data field.
In the current version of CSV Manager (1.2), LineSpec is used to load and save Java Beans,
by providing the get and set method names for each data field.
See BeanLineProvider for more details.
You can subclass LineSpec to add your own
data field specific information for your own custom LineProviders.
You can then access these settings inside your own LineProvider
using the LineSpec object passed into this method.
This method is called after setCsvSpecImpl is called.
setLineSpecImpl in class CustomLineProviderpLineSpec - LineSpec object
ExceptionLineSpec,
setCsvSpecImpl,
BeanLineProvider
protected void setCsvSpecImpl(CsvSpec pCsvSpec)
throws Exception
You can change these using CsvSpec.
setCsvSpecImpl in class CustomLineProviderpCsvSpec - CsvSpec object
ExceptionLineListener.setCsvSpec(com.ricebridge.csvman.CsvSpec),
PROP_Bean_useDefault
protected void startProcessImpl()
throws Exception
Performs some sanity checks on the saving setup.
startProcessImpl in class CustomLineProviderExceptionendProcessImpl
protected boolean hasNextLineImpl()
throws Exception
hasNextLineImpl in class CustomLineProviderExceptionLineProvider.hasNextLine,
nextLineImpl
protected String[] nextLineImpl()
throws Exception
String[] array.
nextLineImpl in class CustomLineProviderExceptionLineProvider.nextLine,
hasNextLineImpl
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||