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

java.lang.Object
  extended by org.homeunix.thecave.buddi.model.impl.ModelObjectImpl
      extended by org.homeunix.thecave.buddi.model.impl.SourceImpl
          extended by org.homeunix.thecave.buddi.model.impl.BudgetCategoryImpl
All Implemented Interfaces:
java.lang.Comparable<ModelObject>, BudgetCategory, Expandable, ModelObject, Source

public class BudgetCategoryImpl
extends SourceImpl
implements BudgetCategory

Default implementation of an BudgetCategory. You should not create this object directly; instead, please use the ModelFactory to create it, as this will ensure that all required fields are correctly set.

Author:
wyatt

Field Summary
 
Fields inherited from class org.homeunix.thecave.buddi.model.impl.SourceImpl
deleted, name, notes
 
Fields inherited from class org.homeunix.thecave.buddi.model.impl.ModelObjectImpl
document, modifiedTime, uid
 
Constructor Summary
BudgetCategoryImpl()
           
 
Method Summary
 int compareTo(ModelObject arg0)
           
 java.util.List<BudgetCategory> getAllChildren()
          Returns a list of all children for this budget category, inluding deleted ones.
 long getAmount(java.util.Date periodDate)
          Returns the budgeted amount associated with the given budget category, for the date in which the given period date exists.
 long getAmount(java.util.Date startDate, java.util.Date endDate)
          Returns the budgeted amount associated with this budget category, over the given date range.
 java.util.Map<java.lang.String,java.lang.Long> getAmounts()
           
 java.util.List<java.util.Date> getBudgetedDates()
          Returns a list of all dates for this budget period which have budget information set for them.
 java.util.List<java.lang.String> getBudgetPeriods(java.util.Date startDate, java.util.Date endDate)
          Returns a list of BudgetPeriods, covering the entire range of periods occupied by startDate to endDate.
 BudgetCategoryType getBudgetPeriodType()
          Returns the Budget Period type.
 java.util.List<BudgetCategory> getChildren()
          Returns a list of children for this budget category.
 java.lang.String getFullName()
          Returns the full name of this source.
 BudgetCategory getParent()
          Returns the parent budget category
 BudgetCategoryType getPeriodType()
           
 boolean isExpanded()
          Is the node currently expanded
 boolean isIncome()
          Does this budget category represent an income category?
 void setAmount(java.util.Date periodDate, long amount)
          Sets the budgeted amount for the given time period.
 void setAmounts(java.util.Map<java.lang.String,java.lang.Long> amounts)
           
 void setDeleted(boolean deleted)
          Sets the deleted status of this source.
 void setExpanded(boolean expanded)
          Should the node be expanded
 void setIncome(boolean income)
          Sets the income flag on this budget category
 void setName(java.lang.String name)
          Sets the name of this source.
 void setParent(BudgetCategory parent)
          Sets the parent for this budget category.
 void setPeriodType(BudgetCategoryType periodType)
          Sets the Budget Period type.
 
Methods inherited from class org.homeunix.thecave.buddi.model.impl.SourceImpl
getName, getNotes, isDeleted, setNotes, toString
 
Methods inherited from class org.homeunix.thecave.buddi.model.impl.ModelObjectImpl
equals, getDocument, getModified, getUid, setChanged, setDocument, setModified, setModified, setUid
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.homeunix.thecave.buddi.model.Source
getName, getNotes, isDeleted, setNotes
 
Methods inherited from interface org.homeunix.thecave.buddi.model.ModelObject
getDocument, getModified, getUid, setChanged, setDocument
 

Constructor Detail

BudgetCategoryImpl

public BudgetCategoryImpl()
Method Detail

getAmounts

public java.util.Map<java.lang.String,java.lang.Long> getAmounts()

setAmounts

public void setAmounts(java.util.Map<java.lang.String,java.lang.Long> amounts)

getAmount

public long getAmount(java.util.Date periodDate)
Returns the budgeted amount associated with the given budget category, for the date in which the given period date exists.

Specified by:
getAmount in interface BudgetCategory
Parameters:
periodDate -
Returns:

setDeleted

public void setDeleted(boolean deleted)
                throws InvalidValueException
Description copied from interface: Source
Sets the deleted status of this source.

Specified by:
setDeleted in interface Source
Overrides:
setDeleted in class SourceImpl
Throws:
InvalidValueException

getChildren

public java.util.List<BudgetCategory> getChildren()
Description copied from interface: BudgetCategory
Returns a list of children for this budget category. The contents of this list will include only children which match the current preferences for deleted items. This means that if the user has specified to only show non-deleted sources, we will not return deleted children here. To get a list of all children, regardles of deleted state, use the getAllChildren() method.

Specified by:
getChildren in interface BudgetCategory
Returns:

getAllChildren

public java.util.List<BudgetCategory> getAllChildren()
Description copied from interface: BudgetCategory
Returns a list of all children for this budget category, inluding deleted ones.

Specified by:
getAllChildren in interface BudgetCategory
Returns:

getAmount

public long getAmount(java.util.Date startDate,
                      java.util.Date endDate)
Description copied from interface: BudgetCategory
Returns the budgeted amount associated with this budget category, over the given date range. If the start and / or end dates do not fall exactly on a budget period, then we calculate how much of the budget period is contained. For instance, assume that we pass in April 15 and July 20 as the dates, and that the associated budget category type is 'Monthly'. Assume that for April we have budgeted $100, for May and June we have budgeted $200 each, and for July we have budgeted $300. To find the final amount, we will add $50 (15 days / 30 days for April * $100) and $200 (May) and $200 (June) and $193 (20 days / 31 days for July * $300), for a total of $643. If you pass in the start date as the first day in the period, and the end day as the last day, you will get back the same number as if you called getAmount(Date) with a day in the same budget period.

Specified by:
getAmount in interface BudgetCategory
Returns:

getBudgetPeriods

public java.util.List<java.lang.String> getBudgetPeriods(java.util.Date startDate,
                                                         java.util.Date endDate)
Returns a list of BudgetPeriods, covering the entire range of periods occupied by startDate to endDate.

Parameters:
startDate -
endDate -
Returns:

setAmount

public void setAmount(java.util.Date periodDate,
                      long amount)
Sets the budgeted amount for the given time period.

Specified by:
setAmount in interface BudgetCategory
Parameters:
periodDate -
amount -

getPeriodType

public BudgetCategoryType getPeriodType()

setPeriodType

public void setPeriodType(BudgetCategoryType periodType)
Description copied from interface: BudgetCategory
Sets the Budget Period type.

Specified by:
setPeriodType in interface BudgetCategory

isIncome

public boolean isIncome()
Description copied from interface: BudgetCategory
Does this budget category represent an income category?

Specified by:
isIncome in interface BudgetCategory
Returns:

setIncome

public void setIncome(boolean income)
Description copied from interface: BudgetCategory
Sets the income flag on this budget category

Specified by:
setIncome in interface BudgetCategory

setName

public void setName(java.lang.String name)
             throws InvalidValueException
Description copied from interface: Source
Sets the name of this source.

Specified by:
setName in interface Source
Overrides:
setName in class SourceImpl
Throws:
InvalidValueException

getParent

public BudgetCategory getParent()
Description copied from interface: BudgetCategory
Returns the parent budget category

Specified by:
getParent in interface BudgetCategory
Returns:

setParent

public void setParent(BudgetCategory parent)
Description copied from interface: BudgetCategory
Sets the parent for this budget category.

Specified by:
setParent in interface BudgetCategory

isExpanded

public boolean isExpanded()
Description copied from interface: Expandable
Is the node currently expanded

Specified by:
isExpanded in interface Expandable
Returns:

setExpanded

public void setExpanded(boolean expanded)
Description copied from interface: Expandable
Should the node be expanded

Specified by:
setExpanded in interface Expandable

getFullName

public java.lang.String getFullName()
Description copied from interface: Source
Returns the full name of this source. The details of this will differ for Accounts and Budget Categories.

Specified by:
getFullName in interface Source
Returns:

getBudgetPeriodType

public BudgetCategoryType getBudgetPeriodType()
Returns the Budget Period type. One of the values in Enum BudgePeriodKeys.

Specified by:
getBudgetPeriodType in interface BudgetCategory
Returns:

compareTo

public int compareTo(ModelObject arg0)
Specified by:
compareTo in interface java.lang.Comparable<ModelObject>
Specified by:
compareTo in interface ModelObject
Overrides:
compareTo in class ModelObjectImpl

getBudgetedDates

public java.util.List<java.util.Date> getBudgetedDates()
Description copied from interface: BudgetCategory
Returns a list of all dates for this budget period which have budget information set for them. We basically look at the budget backing map, and return all keys for non-zero values.

Specified by:
getBudgetedDates in interface BudgetCategory
Returns: