org.salespointframework.core.data
Class MoneyBagImpl
java.lang.Object
org.salespointframework.core.data.AbstractNameable
org.salespointframework.core.data.StockItemImpl
org.salespointframework.core.data.StockImpl<java.lang.Integer,T,CT>
org.salespointframework.core.data.CountingStockImpl<StockItemImpl,CurrencyItemImpl>
org.salespointframework.core.data.MoneyBagImpl
- All Implemented Interfaces:
- java.lang.Cloneable, java.lang.Comparable<java.lang.Object>, java.lang.Iterable<StockItemImpl>, Recoverable, DatasourceChangeListener, ExternalModificationListener, CountingStock<StockItemImpl,CurrencyItemImpl>, DataBasketEntryDestination, DataBasketEntrySource, DataBasketKeys, ListenableStock<StockItemImpl,CurrencyItemImpl>, MoneyBag, Nameable, NameContext, SpAggregate, SpItem, Stock<StockItemImpl,CurrencyItemImpl>, StockItem, SelfManagingDBEDestination<StockItemImpl>, SelfManagingDBESource<StockItemImpl>
public class MoneyBagImpl
- extends CountingStockImpl<StockItemImpl,CurrencyItemImpl>
- implements MoneyBag
Pure Java implementation of the MoneyBag
interface.
- Since:
- v2.0
- Version:
- 2.0 19/08/1999
- Author:
- Steffen Zschaler
Methods inherited from class org.salespointframework.core.data.CountingStockImpl |
add, add, addStock, commitAdd, commitRemove, contains, containsStock, countItems, createPeer, get, internalSetCatalog, remove, remove, remove, rollbackAdd, rollbackRemove |
Methods inherited from class org.salespointframework.core.data.StockImpl |
addStockChangeListener, checkNameChange, clone, compareTo, contains, DatasourceChanged, externalModificationOccurred, fillShallowClone, fillStockWithValue, fireCanEditStockItems, fireCanRemoveStockItems, fireEditingStockItems, fireStockItemsAddCommit, fireStockItemsAdded, fireStockItemsAddRollback, fireStockItemsEditCommit, fireStockItemsEditRollback, fireStockItemsRemoveCommit, fireStockItemsRemoved, fireStockItemsRemoveRollback, getCatalog, getEditingItemsContainer, getItemsContainer, getItemsLock, getNCMonitor, getRefIntegrEditContainer, getRefIntegrItemsContainer, getShallowClone, getTemporaryAddedItemsContainer, getTemporaryRemovedItemsContainer, iterator, iterator, keySet, nameHasChanged, prepareReferentialIntegrity, relinkCatalog, removeStockChangeListener, setEditingItemsContainer, setItemsContainer, setRefIntegrEditContainer, setRefIntegrItemsContainer, setStock, setTemporaryAddedItemsContainer, setTemporaryRemovedItemsContainer, size, sumStock, unsubscribe |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.salespointframework.core.data.interfaces.Stock |
add, addStock, contains, contains, containsStock, countItems, fillStockWithValue, get, getCatalog, iterator, keySet, remove, remove, size, sumStock |
Methods inherited from interface java.lang.Comparable |
compareTo |
Methods inherited from interface org.salespointframework.core.data.interfaces.SpItem |
getName |
Methods inherited from interface java.lang.Iterable |
iterator |
MoneyBagImpl
private MoneyBagImpl(java.lang.String sName,
Catalog c)
- Create a new MoneyBagImpl.
- Parameters:
sName
- the name of the MoneyBag.ac
- the Currency associated to the MoneyBag.temporary
- true, if moneybag should not be persisted
MoneyBagImpl
public MoneyBagImpl(java.lang.String sName,
AbstractCurrency ac,
boolean temporary)
MoneyBagImpl
public MoneyBagImpl(java.lang.String sName,
Catalog c,
boolean temporary)
transferMoney
public void transferMoney(MoneyBag mbDest,
DataBasket db,
NumberValue nvAmount)
- Tries to transfer money from this DataBasket into another one.
- Specified by:
transferMoney
in interface MoneyBag
- Parameters:
mbDest
- the MoneyBag to transfer the money todb
- a transaction DataBasketnvAmount
- the amount of money to transfer
nextUnit
private int nextUnit(MoneyBag mbSrc,
MoneyBag mbDest,
DataBasket db,
Value vToChange,
Value vLimit)
- Searches the optimal way to return the change.
- Parameters:
mbSrc
- the source MoneyBag from which money is removedmbDest
- the destination MoneyBag to which money is addedvToChange
- the amount of money to changevLimit
- the maximum value of currency units to be considered
- Returns:
- an NumberValue indicating success (0) or failure (-1).
nextLowerUnit
private CatalogItem nextLowerUnit(Value vLimit)
- Helper method for
getChange
. Searches and returns the biggest currency unit in this
MoneyBag which is worth less than vLimit
. If there is no matching currency unit,
null
is returnded.
- Parameters:
vLimit
- the limit which the returned currency unit must not exceed.
- Returns:
- a CatalogItem that represents the greatest available currency unit which does not exceed
vLimit
toString
public java.lang.String toString()
- Return a String representation of the MoneyBag.
In addition to the representation created by the super class this will calculate the total amount of
this MoneyBag and append this in formatted form to the end of the representation.
- Overrides:
toString
in class CountingStockImpl<StockItemImpl,CurrencyItemImpl>