SalesPoint Framework v3.0

data.ooimpl
Class StoringStockImpl

java.lang.Object
  |
  +--data.AbstractNameable
        |
        +--data.ooimpl.StockItemImpl
              |
              +--data.ooimpl.StockImpl
                    |
                    +--data.ooimpl.StoringStockImpl

public class StoringStockImpl
extends StockImpl
implements StoringStock

Pure Java implementation of the StoringStock interface.

Since:
v2.0
Version:
2.0 19/08/1999
Author:
Steffen Zschaler
See Also:
Serialized Form

Field Summary
protected  CatalogChangeListener m_cclReferentialIntegrityListener
          Listens to the Stock's Catalog to ensure referential integrity.
protected  int m_nModCount
          Modification counter.
 
Fields inherited from class data.ooimpl.StockImpl
m_cclEditListener, m_ciCatalog, m_cinlCatalogItemNameListener, m_dbCatalogValidator, m_lhListeners, m_sclEditCreatorListener
 
Fields inherited from class data.AbstractNameable
m_ncContext, m_pcsPropertyListeners
 
Constructor Summary
StoringStockImpl(String sName, CatalogImpl ciRef)
          Create a new, initially empty StoringStockImpl.
 
Method Summary
 void add(StockItem si, DataBasket db)
          Add an item to the Stock.
 void commitAdd(DataBasket db, DataBasketEntry dbe)
          Commit the adding of a StockItem.
 void commitRemove(DataBasket db, DataBasketEntry dbe)
          Commit the removal of a StockItem.
 int countItems(String sKey, DataBasket db)
          Count the StockItems with a given key that are visible using a given DataBasket.
protected  StockImpl createPeer()
           
protected  void fillShallowClone(StockImpl stiClone)
          Overridden to accomodate for specific usage of memory.
 Iterator get(String sKey, DataBasket db, boolean fForEdit)
          Iterate all items with a given key.
protected  void internalSetCatalog(CatalogImpl ciRef)
          Overridden because of referential integrity.
 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.
 void rollbackAdd(DataBasket db, DataBasketEntry dbe)
          Rollback the adding of a StockItem.
 void rollbackRemove(DataBasket db, DataBasketEntry dbe)
          Rollback the removal of a StockItem.
protected  void setStock(StockImpl sti)
          Set the Stock and adjust the Catalog link for all Stocks that are contained in this Stock.
 
Methods inherited from class data.ooimpl.StockImpl
addStock, addStockChangeListener, checkNameChange, clone, compareTo, contains, contains, containsStock, fillStockWithValue, fireCanEditStockItems, fireCanRemoveStockItems, fireEditingStockItems, fireStockItemsAddCommit, fireStockItemsAdded, fireStockItemsAddRollback, fireStockItemsEditCommit, fireStockItemsEditRollback, fireStockItemsRemoveCommit, fireStockItemsRemoved, fireStockItemsRemoveRollback, getCatalog, getEditingItemsContainer, getItemsContainer, getItemsLock, getNCMonitor, getRefIntegrEditContainer, getRefIntegrItemsContainer, getShallowClone, getTemporaryAddedItemsContainer, getTemporaryRemovedItemsContainer, iterator, keySet, nameHasChanged, prepareReferentialIntegrity, removeStockChangeListener, setEditingItemsContainer, setItemsContainer, setRefIntegrEditContainer, setRefIntegrItemsContainer, setTemporaryAddedItemsContainer, setTemporaryRemovedItemsContainer, size, sumStock
 
Methods inherited from class data.ooimpl.StockItemImpl
equals, getAssociatedItem, getStock, toString
 
Methods inherited from class data.AbstractNameable
addNameListener, addPropertyChangeListener, attach, detachNC, getName, removeNameListener, removePropertyChangeListener, setName
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_nModCount

protected int m_nModCount
Modification counter. Increases by one with every structural modification.

m_cclReferentialIntegrityListener

protected CatalogChangeListener m_cclReferentialIntegrityListener
Listens to the Stock's Catalog to ensure referential integrity.
Constructor Detail

StoringStockImpl

public StoringStockImpl(String sName,
                        CatalogImpl ciRef)
Create a new, initially empty StoringStockImpl.
Parameters:
sName - the name of the new Stock.
ciRef - the Catalog that is being referenced by the Stock.
Method Detail

internalSetCatalog

protected void internalSetCatalog(CatalogImpl ciRef)
Overridden because of referential integrity.
Override:
Never.
Overrides:
internalSetCatalog in class StockImpl

add

public void add(StockItem si,
                DataBasket db)
Add an item to the Stock.

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.

A addedStockItems event will be fired.

Override:
Never.
Parameters:
si - the item to be added.
db - the DataBasket relative to which the item will be added. Must be either null or a descendant of DataBasketImpl.
Throws:
CatalogConflictException - if the items key is not contained in the corresponding Catalog.
DataBasketConflictException - if the item has already been added/removed using another DataBasket.

get

public Iterator get(String sKey,
                    DataBasket db,
                    boolean fForEdit)
Iterate all items with a given key.

This method, together with Stock.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.

canEditStockItems and editingStockItems events will be fired if fForEdit == true. VetoExceptions will be converted into UnSupportedOperationExceptions.

Override:
Never.
Parameters:
sKey - the key for which to retrieve the StockItems.
db - the DataBasket relative to which to retrieve the StockItems. Must be either null or a descendant of DataBasketImpl.
fForEdit - if true, the StockItems will be retrieved for editing.

countItems

public int countItems(String sKey,
                      DataBasket db)
Count the StockItems with a given key that are visible using a given DataBasket.
Override:
Never.
Parameters:
sKey - the key for which to count the StockItems.
db - the DataBasket that is used to determine visibility. Must be either null or a descendant of DataBasketImpl.

remove

public StockItem remove(String sKey,
                        DataBasket db)
                 throws VetoException
Remove one StockItem with the specified key from the Stock.

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.

canRemoveStockItems and removedStockItems events will be fired.

Override:
Never.
Parameters:
sKey - the key for which to remove an item.
db - the DataBasket relative to which to remove the item. Must be either null or a descendant of DataBasketImpl.
Returns:
the removed item
Throws:
VetoException - if a listener vetoed the removal.
DataBasketConflictException - if the item cannot be removed due to conflicts from DataBasket usage.

remove

public StockItem remove(StockItem si,
                        DataBasket db)
                 throws VetoException
Remove the given StockItem from the Stock.

If the given StockItem is contained in the Stock, it will be removed. The removed item, if any, will be returned.

canRemoveStockItems and removedStockItems events will be fired.

Override:
Never.
Parameters:
si - the StockItem to be removed.
db - the DataBasket relative to which to remove the item. Must be either null or a descendant of DataBasketImpl.
Returns:
the removed item
Throws:
VetoException - if a listener vetoed the removal.
DataBasketConflictException - if the item cannot be removed due to conflicts from DataBasket usage.

fillShallowClone

protected void fillShallowClone(StockImpl stiClone)
Overridden to accomodate for specific usage of memory.
Override:
Never.
Overrides:
fillShallowClone in class StockImpl

createPeer

protected StockImpl createPeer()
Override:
Always.
Overrides:
createPeer in class StockImpl

setStock

protected void setStock(StockImpl sti)
Set the Stock and adjust the Catalog link for all Stocks that are contained in this Stock.
Override:
Never.
Overrides:
setStock in class StockImpl

commitRemove

public void commitRemove(DataBasket db,
                         DataBasketEntry dbe)
Commit the removal of a StockItem.

A commitRemoveStockItems will be fired.

Override:
Never.

rollbackRemove

public void rollbackRemove(DataBasket db,
                           DataBasketEntry dbe)
Rollback the removal of a StockItem.

A rollbackRemoveStockItems will be fired. Also, the Stock will try to make sure, that a corresponding CatalogItem exists.

Override:
Never.

commitAdd

public void commitAdd(DataBasket db,
                      DataBasketEntry dbe)
Commit the adding of a StockItem.

A commitAddStockItems will be fired. A commitEditStockItems event may be fired as a consequence of this method. Also, the Stock will try to make sure, that a corresponding CatalogItem exists.

Override:
Never.

rollbackAdd

public void rollbackAdd(DataBasket db,
                        DataBasketEntry dbe)
Rollback the adding of a StockItem.

A commitAddStockItems will be fired. A commitEditStockItems event may be fired as a consequence of this method.

Override:
Never.

SalesPoint Framework v3.0