public class Database extends Object
An application can register a DatabaseListener to receive events.
| Constructor and Description |
|---|
Database() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAccount(Account parent,
Account child)
Adds an account to a parent.
|
void |
addDatabaseListener(DatabaseListener l) |
void |
addDefaultAccount()
Adds the default account (used by Firefox).
|
void |
changeAccount(Account account)
This doesn't actually affect the data in any way but it does cause an
event to be sent to all registered DatabaseListener objects.
|
Account |
findAccountById(String id)
Locates an account, given an id.
|
Account |
findAccountByUrl(String url)
Searches the database for any account with a matching URL.
|
Account |
findNearestRelative(Account account)
Finds the nearest relative of this node.
|
Account |
findParent(Account account)
Locates the parent account for the given account.
|
List<Account> |
findPathToAccountById(String id) |
List<Account> |
getAllAccounts() |
String |
getGlobalSetting(GlobalSettingKey key)
The preferred way of getting a global setting value.
|
HashMap<String,String> |
getGlobalSettings()
Gets the entire set of global settings.
|
Account |
getRootAccount() |
boolean |
isDirty()
Checks if the db is dirty (needs to be saved).
|
void |
printDatabase()
Debug routine to dump the database.
|
void |
printDatabase(PrintStream stream) |
void |
removeAccount(Account accountToDelete)
Removes an account from a parent account.
|
void |
removeDatabaseListener(DatabaseListener l) |
void |
setDirty(boolean status)
Sets the dirty status and notifies listeners.
|
void |
setGlobalSetting(GlobalSettingKey key,
String value)
The preferred way of setting a global setting.
|
void |
setGlobalSetting(String name,
String value)
Sets a firefox global setting.
|
void |
swapAccounts(Database other)
Is is so that the after an database is loaded, we can reuse this object
This does not swap listeners.
|
String |
toString() |
public Account getRootAccount()
public void swapAccounts(Database other)
other - - the other database to swap withpublic void addAccount(Account parent, Account child) throws Exception
parent - The parent to add the child under.child - The child to add.Exception - On error.public void changeAccount(Account account)
account - The account that was changed.public void removeAccount(Account accountToDelete)
accountToDelete - Duh.public void setGlobalSetting(String name, String value)
name - The name of the setting.value - The value.public void setGlobalSetting(GlobalSettingKey key, String value)
key - the key to usevalue - the value to setpublic HashMap<String,String> getGlobalSettings()
public String getGlobalSetting(GlobalSettingKey key)
key - The key to obtain.public void addDatabaseListener(DatabaseListener l)
public void removeDatabaseListener(DatabaseListener l)
public void addDefaultAccount()
throws Exception
Exception - on exceptionpublic boolean isDirty()
public void setDirty(boolean status)
status - the new dirty statuspublic void printDatabase()
public void printDatabase(PrintStream stream)
public Account findAccountById(String id)
id - The account id (unique hash).public Account findAccountByUrl(String url)
url - The regex to search with.public Account findParent(Account account)
account - The account to find the parent of.public Account findNearestRelative(Account account)
The nearest relative is either the next sibling, previous sibling, or parent in the case where it is an only child. If it is not found to be a member of this tree, null is returned. If you pass in the root node, null is returned.
account - The account to find the nearest relative of.Copyright © 2018. All rights reserved.