org.base.apps.core.data
Class FileData<D>

java.lang.Object
  extended by org.base.apps.util.BaseNameable
      extended by org.base.apps.core.data.BaseData<D>
          extended by org.base.apps.core.data.FileData<D>
All Implemented Interfaces:
ApplicationData<D>, BeanContainer<D>, Nameable, Named

public class FileData<D>
extends BaseData<D>

Implementation of ApplicationData to support file persistence, serializing a bean to and from XML, which is written to and read from the file, respectively.

Author:
Kevan Simpson

Constructor Summary
FileData()
           
FileData(Class<D> beanType)
           
 
Method Summary
protected  void configure(BasePersist persAnnot)
           
protected  File getDataFile()
           
 String getFilename()
           
 void load()
           
protected  D loadData(Class<D> clz)
          Per the application's catalytic BasePersist annotation, attempts to load the application's data and, if successful, setting the data.
 void save()
           
protected  void saveData(D data)
           
 void setFilename(String filename)
           
 
Methods inherited from class org.base.apps.core.data.BaseData
deriveBeanType, getBean, getBeanType, log, setBean, setBeanType
 
Methods inherited from class org.base.apps.util.BaseNameable
getName, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.base.apps.util.Nameable
setName
 
Methods inherited from interface org.base.apps.util.Named
getName
 

Constructor Detail

FileData

public FileData()

FileData

public FileData(Class<D> beanType)
Method Detail

load

public void load()
Specified by:
load in interface ApplicationData<D>
Specified by:
load in class BaseData<D>
See Also:
BaseData.load()

save

public void save()
Specified by:
save in interface ApplicationData<D>
Specified by:
save in class BaseData<D>
See Also:
BaseData.save()

getFilename

public String getFilename()
Returns:
the filename

setFilename

public void setFilename(String filename)
Parameters:
filename - the filename to set

configure

protected void configure(BasePersist persAnnot)
Specified by:
configure in class BaseData<D>
See Also:
BaseData.configure(org.base.apps.api.annot.BasePersist)

getDataFile

protected File getDataFile()

loadData

protected D loadData(Class<D> clz)
              throws Exception
Per the application's catalytic BasePersist annotation, attempts to load the application's data and, if successful, setting the data.

Parameters:
clz - The class of the data to load.
Returns:
The loaded data, possibly but unlikely to be null.
Throws:
Exception - if an error occurs loading data.

saveData

protected void saveData(D data)

Please visit Base Apps, hosted on Sourceforge.net.

Copyright 2011, Blue Agate Software Entity (BASE)