|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.pain.db.PainDB
PAiN Db is a not thread safe semi-object oriented main memory and very buggy database.
PAiN Db is used by PAiN Mud Codebase as persistence engine.
However, PAiN DB is general purpose database, it has great performance,
it's simple, opensource and could be used in any java based opensource projects.
Distributed under the GPL licence
Field Summary | |
boolean |
ALLOW_PLAIN_WRITE
allows use setters outside from transactions -> could not be rolled back (performance issue) but if database will be closed before flush, this changes will be lost |
static java.lang.String |
DB_VERSION
|
boolean |
MANUAL_FLUSH_MODE
MANUAL_FLUSH mode is a kind of delayed commit, user should manually call flush (outside of transaction) to flush all data to disk, if MANUAL_FLUSH_MODE is false every time T1(upper level) transaction commited PainDB will automatically call flush method. |
Constructor Summary | |
PainDB(java.lang.String fileName)
Opens specified database file. |
Method Summary | |
void |
backupTo(java.lang.String backupFileName,
boolean withFlush)
Creates database backup file withFlush should be false if this method is called inside oftransaction (database image created with last flush will be used) |
void |
beginTransaction()
starts the database transaction. |
void |
close()
closes database. |
void |
commitTransaction()
commits the database transaction. |
java.lang.Object |
execute(DbTransaction trans)
same as execute(trans, null); |
java.lang.Object |
execute(DbTransaction trans,
java.lang.Object[] params)
Executes transaction. |
void |
exportToXml(java.lang.String fileName)
Exports all database data to XML file. |
java.util.Iterator |
extentIterator(java.lang.Class clazz)
|
protected void |
finalize()
|
void |
flush()
flushes all changes done after previous flush to disk Called automatically after each upper level transaction commit if MANUAL_FLUSH_MODE is false |
void |
forceClose()
forces database to close. |
DbClass |
getClass(java.lang.Object classId)
|
DbClass |
getDbClass(java.lang.Class javaClazz)
|
java.util.Iterator |
getDbClassesIterator()
|
java.lang.String |
getDbFileName()
|
long |
getDBFileSize()
|
int |
getNumberOfObjectsInDb()
|
DbObject |
getObject(java.lang.Object objectId)
|
DbObject |
getRoot()
root is a simple mark on object, It's allowed to do not have root in DB. |
static PainDB |
importFromXml(java.lang.String xmlFileName,
java.lang.String resultDbFileName)
Creates new database instance, fills it with data from given XML file. |
boolean |
isClosed()
|
boolean |
isDatabaseEmpty()
|
void |
rollbackTransaction()
|
void |
setRoot(DbObject obj)
root is a simple mark on object, db could have not root at all, any time user can null this mark |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String DB_VERSION
public boolean ALLOW_PLAIN_WRITE
public boolean MANUAL_FLUSH_MODE
Constructor Detail |
public PainDB(java.lang.String fileName) throws java.lang.Exception
fileName
- - name of database file
java.lang.Exception
- - if file is corrupted or is not paindb database fileMethod Detail |
public void flush() throws java.io.IOException
java.io.IOException
- if any IO error occurs.
java.lang.RuntimeException
- if there is active transactionpublic DbClass getClass(java.lang.Object classId)
classId
- - OID of the DbClass
public DbObject getObject(java.lang.Object objectId)
objectId
- - serialized unique object id
public void close()
public DbClass getDbClass(java.lang.Class javaClazz)
public DbObject getRoot()
public void setRoot(DbObject obj)
public long getDBFileSize() throws java.io.IOException
java.io.IOException
- if any IO error occured during this method callpublic boolean isDatabaseEmpty()
public int getNumberOfObjectsInDb()
protected void finalize()
public void beginTransaction()
DbTransaction
wrapper class and do not call
this method manually
public void commitTransaction() throws java.io.IOException
DbTransaction
wrapper class and do not call
this method manually
This method will automatically flush all changes to disk if
there no upperlevel transaction and MANUAL_FLUSH_MODE was not set
java.io.IOException
- if any IO problem occurs during flushpublic void rollbackTransaction()
public java.lang.Object execute(DbTransaction trans) throws java.lang.Exception
java.lang.Exception
public java.lang.Object execute(DbTransaction trans, java.lang.Object[] params) throws java.lang.Exception
params
- passed to DbTransaction.execute() method
java.lang.Exception
- if it was thrown in DbTransaction.execute method or if
write error on flush occurspublic java.lang.String getDbFileName()
public boolean isClosed()
public void forceClose()
public void backupTo(java.lang.String backupFileName, boolean withFlush) throws java.io.IOException
withFlush
should be false
if this method is called inside of
backupFileName
- file name for backupwithFlush
- - if true database flush precede to backup
java.io.IOException
public void exportToXml(java.lang.String fileName) throws java.io.IOException
fileName
- = XML file name to export
java.io.IOException
public static PainDB importFromXml(java.lang.String xmlFileName, java.lang.String resultDbFileName) throws java.lang.Exception
xmlFileName
- - XML file with database image to importresultDbFileName
- - name if result database file.
java.lang.Exception
public java.util.Iterator getDbClassesIterator()
public java.util.Iterator extentIterator(java.lang.Class clazz)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |