org.homeunix.thecave.buddi.model.impl
Class ModelFactory

java.lang.Object
  extended by org.homeunix.thecave.buddi.model.impl.ModelFactory

public class ModelFactory
extends java.lang.Object

The factory for all model objects. It is highly recommended to use this class instead of the constructors, for all model objects.

Author:
wyatt

Field Summary
static java.util.Map<java.lang.String,BudgetCategoryType> budgetPeriodTypes
           
 
Constructor Summary
ModelFactory()
           
 
Method Summary
static Account createAccount(java.lang.String name, AccountType type)
          Creates a new Account with the given values
static AccountType createAccountType(java.lang.String name, boolean credit)
          Creates a new AccountType with the given values
static BudgetCategory createBudgetCategory(java.lang.String name, BudgetCategoryType type, boolean income)
          Creates a new BudgetCategory with the given values
static Document createDocument()
          Creates a new data model, with some default types and categories.
static Document createDocument(java.io.File file)
          Attempts to load a data model from file.
static ScheduledTransaction createScheduledTransaction(java.lang.String name, java.lang.String message, java.util.Date startDate, java.util.Date endDate, java.lang.String frequencyType, int scheduleDay, int scheduleWeek, int scheduleMonth, java.lang.String description, long amount, Source from, Source to)
          Creates a new ScheduledTransaction with the given values
static Transaction createTransaction(java.util.Date date, java.lang.String description, long amount, Source from, Source to)
          Creates a new Transaction with the given values
static java.io.File getAutoSaveLocation(java.io.File baseFile)
          Returns the auto save file locaton for the given base file.
static BudgetCategoryType getBudgetCategoryType(BudgetCategoryTypes type)
          Returns the budget category type of the given type, or null if it does not exist.
static BudgetCategoryType getBudgetCategoryType(java.lang.String name)
          Returns the budget category type of the given name, or null if it does not exist.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

budgetPeriodTypes

public static java.util.Map<java.lang.String,BudgetCategoryType> budgetPeriodTypes
Constructor Detail

ModelFactory

public ModelFactory()
Method Detail

getBudgetCategoryType

public static BudgetCategoryType getBudgetCategoryType(BudgetCategoryTypes type)
Returns the budget category type of the given type, or null if it does not exist.

Parameters:
name -
Returns:

getBudgetCategoryType

public static BudgetCategoryType getBudgetCategoryType(java.lang.String name)
Returns the budget category type of the given name, or null if it does not exist.

Parameters:
name -
Returns:

createAccount

public static Account createAccount(java.lang.String name,
                                    AccountType type)
                             throws InvalidValueException
Creates a new Account with the given values

Parameters:
name -
type -
Returns:
Throws:
InvalidValueException

createAccountType

public static AccountType createAccountType(java.lang.String name,
                                            boolean credit)
                                     throws InvalidValueException
Creates a new AccountType with the given values

Parameters:
name -
credit -
Returns:
Throws:
InvalidValueException

createBudgetCategory

public static BudgetCategory createBudgetCategory(java.lang.String name,
                                                  BudgetCategoryType type,
                                                  boolean income)
                                           throws InvalidValueException
Creates a new BudgetCategory with the given values

Parameters:
name -
type -
income -
Returns:
Throws:
InvalidValueException

createDocument

public static Document createDocument()
                               throws ModelException
Creates a new data model, with some default types and categories.

Throws:
ModelException

createDocument

public static Document createDocument(java.io.File file)
                               throws DocumentLoadException,
                                      OperationCancelledException
Attempts to load a data model from file. Works with Buddi 3 format. To load a legacy format, use ModelConverter to get a Bean object, and call the constructor which takes a DataModelBean.

Parameters:
file - File to load
Throws:
DocumentLoadException
OperationCancelledException

createScheduledTransaction

public static ScheduledTransaction createScheduledTransaction(java.lang.String name,
                                                              java.lang.String message,
                                                              java.util.Date startDate,
                                                              java.util.Date endDate,
                                                              java.lang.String frequencyType,
                                                              int scheduleDay,
                                                              int scheduleWeek,
                                                              int scheduleMonth,
                                                              java.lang.String description,
                                                              long amount,
                                                              Source from,
                                                              Source to)
                                                       throws InvalidValueException
Creates a new ScheduledTransaction with the given values

Returns:
Throws:
InvalidValueException

createTransaction

public static Transaction createTransaction(java.util.Date date,
                                            java.lang.String description,
                                            long amount,
                                            Source from,
                                            Source to)
                                     throws InvalidValueException
Creates a new Transaction with the given values

Parameters:
date -
description -
amount -
from -
to -
Returns:
Throws:
InvalidValueException

getAutoSaveLocation

public static java.io.File getAutoSaveLocation(java.io.File baseFile)
Returns the auto save file locaton for the given base file. If the base file is null, return the Preferences directory and a filename of "AutosaveData.buddi3autosave"; if the base file is not null, return the location of the data file, with the extension changed from .buddi3 to .buddi3autosave.

Parameters:
baseFile -
Returns: