|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.dartra.standard.dao.ser.SerDataSource
Data source implementation that accesses DarTra game data in serialized data files.
Subclasses can redefine the readData() and writeData()
methods to change the serialisation mechanism.
Note: to avoid double loading issues you should make sure that you never unintentionally clear and reload a data source. Otherwise you could have 2 objects representing the same thing in memory!
| Constructor Summary | |
SerDataSource(java.lang.String fileName)
Create a new serialisation data source for named data file. |
|
| Method Summary | |
boolean |
exists()
Checks if the data file used by this data source exists on disk. |
org.dartra.framework.dao.Connection |
getConnection()
|
protected DataContainer |
getDataContainer()
Returns the container that holds all data accessible via this data source. |
java.lang.String |
getFileName()
Returns the name of the data file accessed by this data source. |
void |
load()
Load data from the data file. |
protected DataContainer |
readData()
Helper to read data from the data file. |
void |
reset()
Reset the data source: write an empty data file. |
java.lang.String |
toString()
|
void |
write()
Write the data contained by this data source to the data file. |
protected void |
writeData(DataContainer data)
Helper to write data to the data file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public SerDataSource(java.lang.String fileName)
Create a new serialisation data source for named data file.
| Method Detail |
public java.lang.String getFileName()
Returns the name of the data file accessed by this data source.
public org.dartra.framework.dao.Connection getConnection()
throws org.dartra.framework.dao.DataAccessException
getConnection in interface org.dartra.framework.dao.DataSourceorg.dartra.framework.dao.DataAccessException
protected DataContainer getDataContainer()
throws org.dartra.framework.dao.DataAccessException
Returns the container that holds all data accessible via this data source.
org.dartra.framework.dao.DataAccessExceptionpublic boolean exists()
Checks if the data file used by this data source exists on disk.
public void load()
throws org.dartra.framework.dao.DataAccessException
Load data from the data file.
org.dartra.framework.dao.DataAccessException
protected DataContainer readData()
throws org.dartra.framework.dao.DataAccessException
Helper to read data from the data file.
Subclasses can redefine this method if they want to change the serialisation mechanism.
org.dartra.framework.dao.DataAccessException
public void reset()
throws org.dartra.framework.dao.DataAccessException
Reset the data source: write an empty data file.
org.dartra.framework.dao.DataAccessException
public void write()
throws org.dartra.framework.dao.DataAccessException
Write the data contained by this data source to the data file.
org.dartra.framework.dao.DataAccessException
protected void writeData(DataContainer data)
throws org.dartra.framework.dao.DataAccessException
Helper to write data to the data file.
Subclasses can redefine this method if they want to change the serialisation mechanism.
org.dartra.framework.dao.DataAccessExceptionpublic java.lang.String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||