org.jbudget.io
Interface StorageInterface

All Known Implementing Classes:
LocalStore

public interface StorageInterface

An interface that describes common save/read operations.

Author:
petrov

Method Summary
 boolean addAllocation(org.jbudget.Core.Transaction alloation, int cMonth, int cYear)
          saves an Allocation.
 boolean addTransaction(org.jbudget.Core.Transaction transaction, int cMonth, int cYear)
          saves a Transaction.
 void commit()
          Writes all cached objects to 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)
          Returns an account object associated with a given account id.
 org.jbudget.Core.Budget getBudget(int id)
          Returns a budget object associated with the given budget id.
 DataIndex getDataIndex()
          Returns a DataIndex object that describes the stored data.
 java.lang.String getIdString()
          Returns string ID of this instance of the storage interface.
 org.jbudget.Core.Month getMonth(int montn, int year)
          Returns a stored Month object.
 org.jbudget.Core.SharedPreferences getSharedPreferences()
          Returns the SharedPreference object.
 org.jbudget.Core.User getUser(int uid)
          Returns a user object associated with a given user id.
 UserPreferences getUserPreferences(int uid)
          Returns a UserPreference object associated with a given uid
 boolean isNewDataInidex()
          Returns true if a new data index file was created when the Storage object was constructed.
 boolean removeAccount(org.jbudget.Core.Account account)
          removes an account.
 boolean removeAccount(int id)
          removes an 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)
          removes a Month object
 boolean removeMonth(org.jbudget.Core.Month month)
          removes a Month object
 boolean removeTransaction(long transactionId, int cMonth, int cYear)
          removes a Transaction
 boolean removeUser(int uid)
          removes an user.
 boolean removeUser(org.jbudget.Core.User user)
          removes an user.
 boolean storeAccount(org.jbudget.Core.Account account)
          Stores a given account.
 boolean storeBudget(org.jbudget.Core.Budget budget)
          Stores a given budget.
 boolean storeMonth(org.jbudget.Core.Month month)
          Stores a Month object.
 boolean storeUser(org.jbudget.Core.User user)
          Stores a given user.
 boolean storeUserPreferences(int uid, UserPreferences preference)
          Saves a UserPreferences object to permanent storage.
 

Method Detail

getDataIndex

DataIndex getDataIndex()
Returns a DataIndex object that describes the stored data. The DataIndex object returned by this function is in indexing only mode. It cannot be used to get any Month, Budget or other objects. Use corresponding functions to achieve that.


isNewDataInidex

boolean isNewDataInidex()
Returns true if a new data index file was created when the Storage object was constructed. This usually means that a new data directory was initialized


getMonth

org.jbudget.Core.Month getMonth(int montn,
                                int year)
                                throws java.io.IOException
Returns a stored Month object.

Throws:
an - IllegalArguementException if there is no such month
an - IOException if there is a problem reading the Month object.
java.io.IOException

storeMonth

boolean storeMonth(org.jbudget.Core.Month month)
Stores a Month object.

Returns:
true when the Month was successfully saved. For networked storage that means after a confirmation from server was received.

removeMonth

boolean removeMonth(org.jbudget.Core.Month month)
removes a Month object

Returns:
true when the operation has completed successfully.
Throws:
java.lang.IllegalArgumentException - if there is no such Month object

removeMonth

boolean removeMonth(int cMonth,
                    int cYear)
removes a Month object

Returns:
true when the operation has completed successfully.
Throws:
java.lang.IllegalArgumentException - if there is no such Month object

getBudget

org.jbudget.Core.Budget getBudget(int id)
                                  throws java.io.IOException
Returns a budget object associated with the given budget id.

Throws:
java.lang.IllegalArgumentException - if no budget with such an id exists.
java.io.IOException

storeBudget

boolean storeBudget(org.jbudget.Core.Budget budget)
Stores a given budget.

Returns:
true when the operation has completed successfully.

removeBudget

boolean removeBudget(org.jbudget.Core.Budget budget)
removes a budget.

Returns:
true when the operation has completed successfully.
Throws:
java.lang.IllegalArgumentException - if no such budget exists.

removeBudget

boolean removeBudget(int id)
removes a budget.

Returns:
true when the operation has completed successfully.
Throws:
java.lang.IllegalArgumentException - if no such budget exists.

getAccount

org.jbudget.Core.Account getAccount(int id)
                                    throws java.io.IOException
Returns an account object associated with a given account id.

Throws:
java.lang.IllegalArgumentException - if no account with such an id exists.
java.io.IOException

storeAccount

boolean storeAccount(org.jbudget.Core.Account account)
Stores a given account.

Returns:
true when the operation has completed successfully.

removeAccount

boolean removeAccount(org.jbudget.Core.Account account)
removes an account.

Returns:
true when the operation has completed successfully.
Throws:
java.lang.IllegalArgumentException - if no such account exists.

removeAccount

boolean removeAccount(int id)
removes an account.

Returns:
true when the operation has completed successfully.
Throws:
java.lang.IllegalArgumentException - if no such account exists.

getUser

org.jbudget.Core.User getUser(int uid)
                              throws java.io.IOException
Returns a user object associated with a given user id.

Throws:
java.lang.IllegalArgumentException - if no user with such an id exists.
java.io.IOException

storeUser

boolean storeUser(org.jbudget.Core.User user)
Stores a given user.

Returns:
true when the operation has completed successfully.

removeUser

boolean removeUser(org.jbudget.Core.User user)
removes an user.

Returns:
true when the operation has completed successfully.
Throws:
java.lang.IllegalArgumentException - if no such user exists.

removeUser

boolean removeUser(int uid)
removes an user.

Returns:
true when the operation has completed successfully.
Throws:
java.lang.IllegalArgumentException - if no such user exists.

getUserPreferences

UserPreferences getUserPreferences(int uid)
                                   throws java.io.IOException
Returns a UserPreference object associated with a given uid

Throws:
java.io.IOException

storeUserPreferences

boolean storeUserPreferences(int uid,
                             UserPreferences preference)
Saves a UserPreferences object to permanent storage.


addTransaction

boolean addTransaction(org.jbudget.Core.Transaction transaction,
                       int cMonth,
                       int cYear)
                       throws java.io.IOException,
                              JDOMException
saves a Transaction.

Returns:
true when the operation has completed successfully.
Throws:
java.lang.IllegalArgumentException - if Month in which the transaction has happened does not exist.
java.io.IOException
JDOMException

removeTransaction

boolean removeTransaction(long transactionId,
                          int cMonth,
                          int cYear)
                          throws java.io.IOException,
                                 JDOMException
removes a Transaction

Returns:
true when the operation has completed successfully.
Throws:
java.lang.IllegalArgumentException - if Month in which the transaction has happened does not exist or there is no record of this transaction
java.io.IOException
JDOMException

addAllocation

boolean addAllocation(org.jbudget.Core.Transaction alloation,
                      int cMonth,
                      int cYear)
                      throws java.io.IOException,
                             JDOMException
saves an Allocation.

Returns:
true when the operation has completed successfully.
Throws:
java.lang.IllegalArgumentException - if Month in which the allocation has happened does not exist.
java.io.IOException
JDOMException

removeAllocation

boolean removeAllocation(long allocationId,
                         int cMonth,
                         int cYear)
                         throws java.io.IOException,
                                JDOMException
removes an Allocation

Returns:
true when the operation has completed successfully.
Throws:
java.lang.IllegalArgumentException - if Month in which the allocation has happened does not exist or there is no record of this allocation
java.io.IOException
JDOMException

getSharedPreferences

org.jbudget.Core.SharedPreferences getSharedPreferences()
Returns the SharedPreference object.


commit

void commit()
            throws java.io.IOException,
                   JDOMException
Writes all cached objects to permanent storage. It is imperative to call this fununction before the program is terminated. If this is not done, all cached values will be lost.

Throws:
java.io.IOException
JDOMException

getIdString

java.lang.String getIdString()
Returns string ID of this instance of the storage interface.


generateBudgetID

int generateBudgetID()
Creates a new numeric budget id and increases the counter.


generateAccountID

int generateAccountID()
Creates a new numeric account id and increases the counter.


generateExpenseCategoryID

int generateExpenseCategoryID()
Creates a new numeric id for an expense category and increases the counter.


generateIncomeSourceID

int generateIncomeSourceID()
Creates a new numeric id for an income source and increases the counter.


generateUID

int generateUID()
Creates a new uid for a new user and increases the counter.


generateTransactionID

long generateTransactionID()
Creates a new numeric transaction id for and increases the counter.