|
SalesPoint Framework v3.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A Stock.
Stocks are lists that refer to a Catalog
and denote for each CatalogItem
how many
objects of this type are actually available. There are two basically different types of Stocks:
CountingStock
StoringStock
StockItems
that can store
the name of the borrower and the date of borrowing.To suit both types of Stock, StockItems
are introduced. A StockItem refers to a
CatalogItem but can store additional information as well.
Stocks work always on StockItems. They add, remove and search StockItems. They are able to return an Iterator of StockItems for a given key, but can as well just count all StockItems for the same key.
Field Summary |
Fields inherited from interface data.Nameable |
NAME_PROPERTY |
Method Summary | |
void |
add(StockItem si,
DataBasket db)
Add an item to the Stock. |
void |
addStock(Stock st,
DataBasket db,
boolean fRemove)
Add the contents of a Stock to this Stock. |
boolean |
contains(StockItem si,
DataBasket db)
Check whether the Stock contains the given StockItem. |
boolean |
contains(String sKey,
DataBasket db)
Check whether the Stock contains an item with the given key. |
boolean |
containsStock(Stock st,
DataBasket db)
Check whether the given Stock is completely contained in this Stock. |
int |
countItems(String sKey,
DataBasket db)
Count the StockItems with a given key that are visible using a given DataBasket. |
Value |
fillStockWithValue(DataBasket db,
Value vTarget,
StockFromValueCreator sfvc)
Increase the Stock's value by a given value.
|
Iterator |
get(String sKey,
DataBasket db,
boolean fForEdit)
Iterate all items with a given key. |
Catalog |
getCatalog(DataBasket db)
Get the Catalog associated to this Stock. |
Iterator |
iterator(DataBasket db,
boolean fForEdit)
Iterate all items in the Stock. |
Set |
keySet(DataBasket db)
Return the set of keys for which StockItems are visible using the given DataBasket.
|
StockItem |
remove(StockItem si,
DataBasket db)
Remove the given StockItem from the Stock. |
StockItem |
remove(String sKey,
DataBasket db)
Remove one StockItem with the specified key from the Stock. |
int |
size(DataBasket db)
Get the size of this Stock. |
Value |
sumStock(DataBasket db,
CatalogItemValue civ,
Value vInit)
Sum up the Stock. |
Methods inherited from interface data.StockItem |
clone, getAssociatedItem, getStock |
Methods inherited from interface java.lang.Comparable |
compareTo |
Methods inherited from interface data.Nameable |
addNameListener, addPropertyChangeListener, attach, detachNC, getName, removeNameListener, removePropertyChangeListener, setName |
Method Detail |
public void add(StockItem si, DataBasket db)
The item will only be visible to users of the same DataBasket. Only after a DataBasket.commit()
was performed on the DataBasket, the item will become visible to other users.
For a ListenableStock
a addedStockItems
event will be fired.
si
- the item to be added.db
- the DataBasket relative to which the item will be added.
CatalogConflictException
- if the items key is not contained in the corresponding Catalog
.
DataBasketConflictException
- if the item has already been added/removed using another DataBasket.public void addStock(Stock st, DataBasket db, boolean fRemove)
add(data.StockItem, data.DataBasket)
for each item in
the source Stock so the same constraints apply and the same exceptions may be thrown.
st
- the Stock whose contents is to be added to this Stock.db
- the DataBasket relative to which to perform the actions. addStock
will add all
items from the source Stock that are visible using this DataBasket.fRemove
- if true, the items will be removed from the source Stock prior to adding them to this
Stock. Otherwise, they will be cloned prior to adding them to the Stock.public Iterator get(String sKey, DataBasket db, boolean fForEdit)
This method, together with iterator(data.DataBasket, boolean)
is the only way of accessing the individual
StockItems
contained in a Stock. The iterator will deliver all items that have the
specified key and are visible using the given DataBasket. Depending on the fForEdit
parameter, the items will be retrieved in different ways. See DataBasket
for an explanation of
the different possibilities.
For a ListenableStock
canEditStockItems
and editingStockItems
events
will be fired if fForEdit
== true. VetoExceptions
will be converted
into UnSupportedOperationException
s.
sKey
- the key for which to retrieve the StockItems.db
- the DataBasket relative to which to retrieve the StockItems.fForEdit
- if true, the StockItems will be retrieved for editing.public int countItems(String sKey, DataBasket db)
sKey
- the key for which to count the StockItems.db
- the DataBasket that is used to determine visibility.public boolean contains(String sKey, DataBasket db)
Equivalent to:(
.countItems(java.lang.String, data.DataBasket)
(sKey, db) > 0)
sKey
- the key for which to check containment.db
- the DataBasket used to check visibility.public boolean contains(StockItem si, DataBasket db)
Return true if the Stock contains a StockItem that is equal to the given one.
si
- the StockItem for which to check containment.db
- the DataBasket used to check visibility.public boolean containsStock(Stock st, DataBasket db)
Conceptually calls contains(data.StockItem, data.DataBasket)
for each item in the given Stock.
st
- the Stock for which to check containment.db
- the DataBasket used to determine visibility.public StockItem remove(String sKey, DataBasket db) throws VetoException
If there are any StockItems with the specified key, one will be removed. There is no guarantee as to which StockItem will be removed. The removed item, if any, will be returned.
For a ListenableStock
canRemoveStockItems
and removedStockItems
events will be fired.
sKey
- the key for which to remove an item.db
- the DataBasket relative to which to remove the item.
VetoException
- if a listener vetoed the removal.
DataBasketConflictException
- if the item cannot be removed due to conflicts from DataBasket
usage.public StockItem remove(StockItem si, DataBasket db) throws VetoException
If the given StockItem is contained in the Stock, it will be removed. The removed item, if any, will be returned.
For a ListenableStock
canRemoveStockItems
and removedStockItems
events will be fired.
si
- the StockItem to be removed.db
- the DataBasket relative to which to remove the item.
VetoException
- if a listener vetoed the removal.
DataBasketConflictException
- if the item cannot be removed due to conflicts from DataBasket
usage.public Iterator iterator(DataBasket db, boolean fForEdit)
This method, together with get(java.lang.String, data.DataBasket, boolean)
is the only way of accessing the individual
StockItems
contained in a Stock. The iterator will deliver all items that are visible
using the given DataBasket. Depending on the fForEdit
parameter, the items will be retrieved
in different ways. See DataBasket
for an explanation of the different possibilities.
For a ListenableStock
canEditStockItems
and editingStockItems
events
will be fired if fForEdit
== true. VetoExceptions
will be converted
into UnSupportedOperationException
s.
db
- the DataBasket relative to which to retrieve the StockItems.fForEdit
- if true, the StockItems will be retrieved for editing.public Set keySet(DataBasket db)
StockItems
are visible using the given DataBasket.
The returned set is static and gives the state of the Stock at the time of the call. It will not automatically update when the contents of the Stock changes.
db
- the DataBasket used for determining visibility.public Value sumStock(DataBasket db, CatalogItemValue civ, Value vInit)
The method will determine the value of each CatalogItem
in the associated Catalog and
multiply
this by
the number of StockItems for the respective key
. These products will be
added up
and the resulting total will be returned.
db
- the DataBasket that is used to determine visibility.civ
- the CatalogItemValue used for determining the value of a CatalogItem.vInit
- the initial value. The sum of the Stock will be added to this value.
vInit
, only with a changed value.public Value fillStockWithValue(DataBasket db, Value vTarget, StockFromValueCreator sfvc)
Stock's value
by a given value.
The method will try to break the given value as exactly as possible into StockItems that will be added to the Stock. The actual algorithm used for breaking up the value will be determined by the last parameter. The return value of the method will specify the remaining value that could not be represented by StockItems by the given algorithm.
db
- the DataBasket relative to which to perform the operation.vTarget
- the value by which to increase the Stock's total value.sfvc
- the strategy used to fill the Stock.
public int size(DataBasket db)
db
- the DataBasket used to determine visibility.public Catalog getCatalog(DataBasket db)
For a substock of another stock this is essentially equivalent to
Catalog cReturn = (Catalog)getAssociatedItem
(db); if (cReturn != null) { return cReturn; } else { throw newDataBasketConflictException
(); }
db
- a DataBasket determinig visibility of the stock's catalog.
|
SalesPoint Framework v3.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |