|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jbudget.io.LocalStore
public class LocalStore
| Field Summary | |
|---|---|
private java.util.Map<java.lang.Integer,Element> |
accountElementsMap
A map of JDOM Elements for Account objects that were loaded from the storage. |
private java.util.Map<java.lang.Integer,Element> |
budgetElementsMap
A map of JDOM Elements for Budget objects that were loaded from the storage. |
private DataIndex |
dataIndex
Index of available data |
private java.util.Map<java.lang.Integer,Element> |
monthElementsMap
A map of JDOM Elements for Month objects that were loaded from the storage. |
private boolean |
newDataIndexFlag
A flag that is set to true when a new DataIndex is created. |
private java.io.File |
rootDirectory
Root directory for storing all the data |
private org.jbudget.Core.SharedPreferences |
sharedPreferences
Global SharedPreference object used by the program. |
private java.util.Map<java.lang.Integer,Element> |
userElementsMap
A map of JDOM Elements for User objects that were loaded from the storage. |
private java.util.Map<java.lang.Integer,Element> |
userPreferencesElementsMap
A map of JDOM Elements for UserPreferences objects that were loaded from the storage. |
| Constructor Summary | |
|---|---|
LocalStore(java.io.File rootDirectory)
Creates a new instance of LocalStore |
|
LocalStore(java.lang.String rootDirectoryStr)
Creates a new instance of LocalStore |
|
| Method Summary | |
|---|---|
boolean |
addAllocation(org.jbudget.Core.Transaction allocation,
int cMonth,
int cYear)
saves an Allocation. |
boolean |
addTransaction(org.jbudget.Core.Transaction transaction,
int cMonth,
int cYear)
saves a Transaction. |
private void |
backupFile(java.io.File file)
Creates a backup of a given file. |
void |
commit()
Writes all JDOME elements stored in the cache and the data index to the permanent storage. |
int |
generateAccountID()
Creates a new numeric account id and increases the counter. |
int |
generateBudgetID()
Creates a new numeric budget id and increases the counter. |
int |
generateExpenseCategoryID()
Creates a new numeric id for an expense category and increases the counter. |
int |
generateIncomeSourceID()
Creates a new numeric id for an income source and increases the counter. |
long |
generateTransactionID()
Creates a new numeric transaction id for and increases the counter. |
int |
generateUID()
Creates a new uid for a new user and increases the counter. |
org.jbudget.Core.Account |
getAccount(int id)
Implementing the interface. |
private Element |
getAccountElement(int id)
Returns a JDOM Element containing the account with given id. |
private java.io.File |
getAccountFile(int id)
Returns a File object that is initialized to point to the xml file corresponing to the Account with a given id. |
org.jbudget.Core.Budget |
getBudget(int id)
Implementing the interface. |
private Element |
getBudgetElement(int id)
Returns a JDOM Element containing the budget with given id. |
private java.io.File |
getBudgetFile(int id)
Returns a File object that is initialized to point to the xml file corresponing to the Budget with a given id. |
DataIndex |
getDataIndex()
Interface implementation |
java.lang.String |
getIdString()
Returns string ID of this instance of the storage interface. |
org.jbudget.Core.Month |
getMonth(int cMonth,
int cYear)
Implementing the interface. |
private Element |
getMonthElement(int month,
int year)
Returns a JDOM element that corresponds to the given month. |
private java.io.File |
getMonthFile(int cMonth,
int cYear)
Returns a File object that is initialized to point to the xml file corresponding to the given month |
org.jbudget.Core.SharedPreferences |
getSharedPreferences()
Returns the SharedPrefences object used by the program. |
private java.io.File |
getSharedPreferencesFile()
|
org.jbudget.Core.User |
getUser(int uid)
Implementing the interface. |
private Element |
getUserElement(int uid)
Returns a JDOM Element containing the user with a given uid. |
private java.io.File |
getUserFile(int uid)
Returns a File object that is initialized to point to the xml file corresponing to the User with a given uid. |
UserPreferences |
getUserPreferences(int uid)
Implementing the interface. |
private Element |
getUserPreferencesElement(int uid)
Returns a JDOM Element containing the user preferences for the user with a given uid. |
private java.io.File |
getUserPreferencesFile(int uid)
Returns a File object that is initialized to point to the xml file corresponing to the UserPreferences for the user with a given uid. |
private void |
initialize()
Makes sure that the root directory for storing all the files exists. |
private void |
initializeIndex()
Initializes an index of available data. |
boolean |
isNewDataInidex()
Returns true if a new data index file was created when the Storage object was constructed. |
private Element |
readAccountElement(int id)
Reads a JDOM Element containing the account with given account id. |
private Element |
readBudgetElement(int id)
Reads a JDOM Element containing the budget with given budget id. |
private Element |
readMonthElement(int cMonth,
int cYear)
Reads a JDOM Element for a given Month from a corresponding file. |
private Element |
readSharedPreferencesElement()
Reads a JDOM Element containing the user preferences for a user with a given uid. |
private Element |
readUserElement(int uid)
Reads a JDOM Element containing the user with a given uid. |
private Element |
readUserPreferencesElement(int uid)
Reads a JDOM Element containing the user preferences for a user with a given uid. |
boolean |
removeAccount(org.jbudget.Core.Account account)
removes a account. |
boolean |
removeAccount(int id)
removes a account. |
boolean |
removeAllocation(long allocationID,
int cMonth,
int cYear)
removes an Allocation |
boolean |
removeBudget(org.jbudget.Core.Budget budget)
removes a budget. |
boolean |
removeBudget(int id)
removes a budget. |
boolean |
removeMonth(int cMonth,
int cYear)
Implementing the interfaces. |
boolean |
removeMonth(org.jbudget.Core.Month month)
Implementing the interfaces. |
boolean |
removeTransaction(long transactionID,
int cMonth,
int cYear)
removes a Transaction |
boolean |
removeUser(int uid)
removes a user. |
boolean |
removeUser(org.jbudget.Core.User user)
removes a user. |
private void |
saveAccountElement(Element element,
int id)
Saves a JDOM Element containing the account with given account id. |
private void |
saveBudgetElement(Element element,
int id)
Saves a JDOM Element containing the budget with given budget id. |
private void |
saveMonthElement(Element element,
int cMonth,
int cYear)
Stores a JDOM Element corresponding to a Month object to a file. |
private void |
saveSharedPreferences()
|
private void |
saveSharedPreferencesElement(Element element)
Saves a JDOM Element containing the user preferences for a user with a given uid. |
private void |
saveUserElement(Element element,
int uid)
Saves a JDOM Element containing the user with given uid. |
private void |
saveUserPreferencesElement(Element element,
int uid)
Saves a JDOM Element containing the user preferences for a user with a given uid. |
boolean |
storeAccount(org.jbudget.Core.Account account)
Stores a given account. |
boolean |
storeBudget(org.jbudget.Core.Budget budget)
Stores a given budget. |
private void |
storeIndex()
Saves the index of available data to a file |
boolean |
storeMonth(org.jbudget.Core.Month month)
Implementing the interface. |
boolean |
storeUser(org.jbudget.Core.User user)
Stores a given user. |
boolean |
storeUserPreferences(int uid,
UserPreferences preferences)
Stores the preferences for the user with a given uid. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final java.io.File rootDirectory
private DataIndex dataIndex
private boolean newDataIndexFlag
private final java.util.Map<java.lang.Integer,Element> monthElementsMap
private final java.util.Map<java.lang.Integer,Element> budgetElementsMap
private final java.util.Map<java.lang.Integer,Element> accountElementsMap
private final java.util.Map<java.lang.Integer,Element> userElementsMap
private final java.util.Map<java.lang.Integer,Element> userPreferencesElementsMap
private org.jbudget.Core.SharedPreferences sharedPreferences
| Constructor Detail |
|---|
public LocalStore(java.io.File rootDirectory)
throws java.io.IOException,
JDOMException
java.io.IOException
JDOMException
public LocalStore(java.lang.String rootDirectoryStr)
throws java.io.IOException,
JDOMException
java.io.IOException
JDOMException| Method Detail |
|---|
private void initialize()
throws java.io.IOException,
JDOMException
java.io.IOException
JDOMException
private void initializeIndex()
throws JDOMException,
java.io.IOException
JDOMException
java.io.IOException
private void storeIndex()
throws java.io.IOException
java.io.IOExceptionpublic DataIndex getDataIndex()
getDataIndex in interface StorageInterfacepublic boolean isNewDataInidex()
StorageInterface
isNewDataInidex in interface StorageInterface
private Element readMonthElement(int cMonth,
int cYear)
throws java.io.IOException,
JDOMException
java.io.IOException - if there is a problem reading the file.
JDOMExceptoin - if there is a problem parsing the contents of
the file.
JDOMException
private void saveMonthElement(Element element,
int cMonth,
int cYear)
throws java.io.IOException,
JDOMException
java.io.IOException - if there are IO errors.
JDOMException
private Element getMonthElement(int month,
int year)
throws java.io.IOException,
JDOMException
java.lang.IllegalArgumentException - if month is not available.
java.io.IOException
JDOMException
public org.jbudget.Core.Month getMonth(int cMonth,
int cYear)
throws java.io.IOException
getMonth in interface StorageInterfacejava.io.IOException - if there are IO errors.
JDOMException - if there are parsing errors.public boolean storeMonth(org.jbudget.Core.Month month)
storeMonth in interface StorageInterface
public boolean removeMonth(int cMonth,
int cYear)
removeMonth in interface StorageInterfacejava.lang.IllegalArgumentException - if there is no such monthpublic boolean removeMonth(org.jbudget.Core.Month month)
removeMonth in interface StorageInterfacejava.lang.IllegalArgumentException - if there is no such month
private Element readBudgetElement(int id)
throws java.io.IOException,
JDOMException
java.io.IOException
java.lang.IllegalArgumentException - if there is no such budget.
JDOMException
private void saveBudgetElement(Element element,
int id)
throws java.io.IOException,
JDOMException
java.io.IOException
JDOMException
private Element getBudgetElement(int id)
throws java.io.IOException,
JDOMException
java.lang.IllegalArgumentException - if there is no budget with the given id
java.io.IOException
JDOMException
public org.jbudget.Core.Budget getBudget(int id)
throws java.io.IOException
getBudget in interface StorageInterfacejava.lang.IllegalArgumentException - if there is no budget with the given id
java.io.IOException - if there are IO errors.public boolean storeBudget(org.jbudget.Core.Budget budget)
storeBudget in interface StorageInterfacepublic boolean removeBudget(int id)
removeBudget in interface StorageInterfacejava.lang.IllegalArgumentException - if no such budget exists.public boolean removeBudget(org.jbudget.Core.Budget budget)
removeBudget in interface StorageInterfacejava.lang.IllegalArgumentException - if no such budget exists.
private Element readAccountElement(int id)
throws java.io.IOException,
JDOMException
java.io.IOException
java.lang.IllegalArgumentException - if there is no such account.
JDOMException
private void saveAccountElement(Element element,
int id)
throws java.io.IOException,
JDOMException
java.io.IOException
JDOMException
private Element getAccountElement(int id)
throws java.io.IOException,
JDOMException
java.lang.IllegalArgumentException - if there is no account with the given id
java.io.IOException
JDOMException
public org.jbudget.Core.Account getAccount(int id)
throws java.io.IOException
getAccount in interface StorageInterfacejava.lang.IllegalArgumentException - if there is no account with the given id
java.io.IOException - if there are IO errors.public boolean storeAccount(org.jbudget.Core.Account account)
storeAccount in interface StorageInterfacepublic boolean removeAccount(int id)
removeAccount in interface StorageInterfacejava.lang.IllegalArgumentException - if no such account exists.public boolean removeAccount(org.jbudget.Core.Account account)
removeAccount in interface StorageInterfacejava.lang.IllegalArgumentException - if no such account exists.
private Element readUserElement(int uid)
throws java.io.IOException,
JDOMException
java.io.IOException
java.lang.IllegalArgumentException - if there is no such user.
JDOMException
private void saveUserElement(Element element,
int uid)
throws java.io.IOException,
JDOMException
java.io.IOException
JDOMException
private Element getUserElement(int uid)
throws java.io.IOException,
JDOMException
java.lang.IllegalArgumentException - if there is no user with the given id
java.io.IOException
JDOMException
public org.jbudget.Core.User getUser(int uid)
throws java.io.IOException
getUser in interface StorageInterfacejava.lang.IllegalArgumentException - if there is no user with the given uid
java.io.IOException - if there are IO errors.public boolean storeUser(org.jbudget.Core.User user)
storeUser in interface StorageInterfacepublic boolean removeUser(int uid)
removeUser in interface StorageInterfacejava.lang.IllegalArgumentException - if no such user exists.public boolean removeUser(org.jbudget.Core.User user)
removeUser in interface StorageInterfacejava.lang.IllegalArgumentException - if no such user exists.
private Element readUserPreferencesElement(int uid)
throws java.io.IOException,
JDOMException
java.io.IOException
java.lang.IllegalArgumentException - if there is no such user.
JDOMException
private void saveUserPreferencesElement(Element element,
int uid)
throws java.io.IOException,
JDOMException
java.io.IOException
JDOMException
private Element getUserPreferencesElement(int uid)
throws java.io.IOException,
JDOMException
java.lang.IllegalArgumentException - if there is no user with the given id
java.io.IOException
JDOMException
public UserPreferences getUserPreferences(int uid)
throws java.io.IOException
getUserPreferences in interface StorageInterfacejava.lang.IllegalArgumentException - if there is no user with the given uid
java.io.IOException - if there are IO errors.
public boolean storeUserPreferences(int uid,
UserPreferences preferences)
storeUserPreferences in interface StorageInterface
private Element readSharedPreferencesElement()
throws java.io.IOException,
JDOMException
java.io.IOException
java.lang.IllegalArgumentException - if there is no such user.
JDOMException
private void saveSharedPreferencesElement(Element element)
throws java.io.IOException,
JDOMException
java.io.IOException
JDOMExceptionpublic org.jbudget.Core.SharedPreferences getSharedPreferences()
getSharedPreferences in interface StorageInterface
private void saveSharedPreferences()
throws java.io.IOException,
JDOMException
java.io.IOException
JDOMException
public boolean addTransaction(org.jbudget.Core.Transaction transaction,
int cMonth,
int cYear)
throws java.io.IOException,
JDOMException
StorageInterface
addTransaction in interface StorageInterfacejava.io.IOException
JDOMException
public boolean removeTransaction(long transactionID,
int cMonth,
int cYear)
throws java.io.IOException,
JDOMException
StorageInterface
removeTransaction in interface StorageInterfacejava.io.IOException
JDOMException
public boolean addAllocation(org.jbudget.Core.Transaction allocation,
int cMonth,
int cYear)
throws java.io.IOException,
JDOMException
StorageInterface
addAllocation in interface StorageInterfacejava.io.IOException
JDOMException
public boolean removeAllocation(long allocationID,
int cMonth,
int cYear)
throws java.io.IOException,
JDOMException
StorageInterface
removeAllocation in interface StorageInterfacejava.io.IOException
JDOMException
public void commit()
throws java.io.IOException,
JDOMException
commit in interface StorageInterfacejava.io.IOException
JDOMExceptionpublic java.lang.String getIdString()
getIdString in interface StorageInterface
private java.io.File getMonthFile(int cMonth,
int cYear)
private java.io.File getBudgetFile(int id)
private java.io.File getAccountFile(int id)
private java.io.File getUserFile(int uid)
private java.io.File getUserPreferencesFile(int uid)
private java.io.File getSharedPreferencesFile()
public int generateBudgetID()
generateBudgetID in interface StorageInterfacepublic int generateAccountID()
generateAccountID in interface StorageInterfacepublic int generateExpenseCategoryID()
generateExpenseCategoryID in interface StorageInterfacepublic int generateIncomeSourceID()
generateIncomeSourceID in interface StorageInterfacepublic int generateUID()
generateUID in interface StorageInterfacepublic long generateTransactionID()
generateTransactionID in interface StorageInterface
private void backupFile(java.io.File file)
throws java.io.IOException
java.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||