|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.database.SafeDBAccess
| Field Summary | |
protected EntriesView |
anyView
|
protected File |
directory
|
boolean |
disableRestore
Set this true to temporarily disable restoring from a backup. |
boolean |
isUpdating
If the Database is open for updating, this will be true. |
Lock |
lock
All operations are synchronized on this lock. |
DatabaseMaker |
maker
This is the DatabaseMaker used to open the Database. |
protected String |
name
|
Database |
opened
This is the currently open Database. |
String |
openMode
If the Database is opened, this is the mode it was opened in. |
protected String |
previousMode
|
protected String[] |
sortNames
|
protected int |
updateCount
|
protected Hashtable |
views
|
| Constructor Summary | |
SafeDBAccess(File directory,
String dbName,
String[] sortNames)
Create a SafeDBAccess object. |
|
| Method Summary | |
boolean |
abortUpdate()
Abort the update process, close the db and do not rename the temp file to ".db". |
boolean |
backupExists()
Check if a backup for the database exists. |
boolean |
backupNow()
This causes the database to be closed (if it is not open for updating) and then backed up. |
boolean |
close()
Close the database if it is not open for updating. |
void |
closeCreate()
Call this after initializing with openForCreate(). |
boolean |
create(Object initializer)
This calls openForCreate() and then calls closeCreate(). |
protected void |
databaseClosed()
This is called when the database has been closed. |
boolean |
databaseExists()
Check if the database does exist. |
protected void |
databaseOpened(Database db,
String mode,
boolean forUpdate)
This gets called when the DB has been successfully opened. |
boolean |
endUpdate()
End the update process. |
EntriesView |
getAnyView()
|
Time |
getBackupModifiedTime()
Return the time the backup was last made. |
Time |
getDatabaseModifiedTime(Time dest)
Return the time the dabase was last modified. |
EntriesView |
getView(String sortName)
This gets the EntriesView created when the Database was opened for the specified sortName. |
protected void |
makeBackup()
This makes a backup of the database. |
Database |
open(String mode)
Open the database in either "r" or "rw" mode. |
Database |
openForCreate(Object initializer)
Open the database for creation only if it does not already exist. |
protected void |
restore()
This restores the dabase from the backup file if one exists. |
Database |
startUpdate()
Close the database if it is open, make a backup and then open it in "rw" mode for updating. |
long |
timeSinceBackup(Time since)
Return the time elapsed in milliseconds between the last backup time and the provided Time. |
void |
verifyBackup()
If no backup exists at all, make it now. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Field Detail |
protected File directory
protected String name
protected String[] sortNames
protected String previousMode
protected int updateCount
protected Hashtable views
protected EntriesView anyView
public Database opened
public String openMode
public boolean isUpdating
public Lock lock
public DatabaseMaker maker
public boolean disableRestore
| Constructor Detail |
public SafeDBAccess(File directory,
String dbName,
String[] sortNames)
directory - The directory which contains the database.dbName - The root name (without the ".db" extension) of the database.sortNames - an optional set of sortNames for which EntriesView objects
will be created.| Method Detail |
public EntriesView getView(String sortName)
sortName - one of the sortNames provided in the constructor.
public EntriesView getAnyView()
protected void databaseOpened(Database db,
String mode,
boolean forUpdate)
db - the open database.mode - the mode it was opened in.forUpdate - true if has been opened for updating.protected void databaseClosed()
protected void restore()
throws IOException
IOException - if disableRestore is true.
RestoreException - if there is any problem restoring the database, including a missing
or invalid backup zip file.
protected void makeBackup()
throws BackupException
BackupException - if an error occurs.
public boolean close()
throws IOException
IOException - on an IOError.
public Database open(String mode)
throws IOException
mode - either "r" or "rw" - any other value will generate an IllegalArgumentException
IOException - on any IO error.
IllegalArgumentException - if the mode is invalid.
public boolean create(Object initializer)
throws IOException
initializer - the initializer used to initialize the database, which must be
non-null.
IOException - if an IO error occurs during creation.
public Database openForCreate(Object initializer)
throws IOException
initializer - an optional Object used to initialize the sorts and fields.
IOException - if an error occurs.
public void closeCreate()
throws IOException
IOException
public Database startUpdate()
throws IOException
You can call startUpdate() multiple times but for each call to startUpdate() there must be a corresponding call to endUpdate(). Update mode is only exited when the last endUpdate() is called.
IOException - if an IO error occurs.
public boolean abortUpdate()
throws IOException
IOException - if an IOException occurs.
public boolean endUpdate()
throws IOException
IOException - if an IOException occurs.
public boolean backupNow()
throws IOException
IOException - if an IO error occurs.
public void verifyBackup()
throws IOException
IOException - if an IO error occurs.public boolean backupExists()
public Time getBackupModifiedTime()
public long timeSinceBackup(Time since)
since - the Time to compare to the backup time, or null to use the current time.
public boolean databaseExists()
public Time getDatabaseModifiedTime(Time dest)
dest - an optional destination Time.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||