SalesPoint Framework v3.1

data.filters
Class CountingStockFilter

java.lang.Object
  extended bydata.filters.AbstractStockFilter
      extended bydata.filters.CountingStockFilter
All Implemented Interfaces:
Cloneable, Comparable, CountingStock, DataBasketEntryDestination, DataBasketEntrySource, EventListener, ListenableStock, Nameable, Serializable, Stock, StockChangeListener, StockItem
Direct Known Subclasses:
MoneyBagFilter

public abstract class CountingStockFilter
extends AbstractStockFilter
implements CountingStock

StockFilter for CountingStocks.

The filter condition will be defined by overriding method countItems(java.lang.String, data.DataBasket).

Since:
v2.0
Author:
Steffen Zschaler
See Also:
Serialized Form

Field Summary
 
Fields inherited from class data.filters.AbstractStockFilter
m_lhListeners, m_stSource
 
Fields inherited from interface data.Nameable
NAME_PROPERTY
 
Constructor Summary
CountingStockFilter(CountingStock csSource)
          Create a new CountingStockFilter.
 
Method Summary
 void add(String sKey, int nCount, DataBasket db)
          Add the specified number of items to the source Stock.
 boolean contains(StockItem si, DataBasket db)
          Check whether the filtered Stock contains the given StockItem.
 boolean containsStock(Stock st, DataBasket db)
          Check whether the filtered Stock contains the given Stock.
abstract  int countItems(String sKey, DataBasket db)
          Count the items of the given key in the filtered Stock.
 Iterator get(String sKey, DataBasket db, boolean fForEdit)
          Return all items with the given key that are contained in the filtered Stock.
 void remove(String sKey, int nCount, DataBasket db)
          Remove at most the specified number of items from the source Stock.
 
Methods inherited from class data.filters.AbstractStockFilter
add, addedStockItems, addNameListener, addPropertyChangeListener, addStock, addStockChangeListener, attach, canEditStockItems, canRemoveStockItems, clone, commitAddStockItems, commitEditStockItems, commitRemoveStockItems, compareTo, contains, detachNC, editingStockItems, fillStockWithValue, fireCanEditStockItems, fireCanRemoveStockItems, fireEditingStockItems, fireStockItemsAddCommit, fireStockItemsAdded, fireStockItemsAddRollback, fireStockItemsEditCommit, fireStockItemsEditRollback, fireStockItemsNoEdit, fireStockItemsNoRemove, fireStockItemsRemoveCommit, fireStockItemsRemoved, fireStockItemsRemoveRollback, getAssociatedItem, getCatalog, getMainStock, getName, getStock, iterator, keySet, noEditStockItems, noRemoveStockItems, remove, remove, removedStockItems, removeNameListener, removePropertyChangeListener, removeStockChangeListener, rollbackAddStockItems, rollbackEditStockItems, rollbackRemoveStockItems, setName, size, sumStock
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface data.Stock
add, addStock, contains, fillStockWithValue, getCatalog, iterator, keySet, remove, remove, size, sumStock
 
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
 

Constructor Detail

CountingStockFilter

public CountingStockFilter(CountingStock csSource)
Create a new CountingStockFilter.

Parameters:
csSource - the source Stock.
Method Detail

get

public Iterator get(String sKey,
                    DataBasket db,
                    boolean fForEdit)
Return all items with the given key that are contained in the filtered Stock.

Specified by:
get in interface Stock
Parameters:
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.
Override:
Never

countItems

public abstract int countItems(String sKey,
                               DataBasket db)
Count the items of the given key in the filtered Stock.

This method must be overridden, as it represents the filter condition. All other methods that use or return filtered values will call this method.

Specified by:
countItems in interface Stock
Parameters:
sKey - the key for which to count the StockItems.
db - the DataBasket that is used to determine visibility.
Override:
Always This method must be overridden, as it represents the filter condition. All other methods that use or return filtered values will call this method.

contains

public boolean contains(StockItem si,
                        DataBasket db)
Check whether the filtered Stock contains the given StockItem.

Specified by:
contains in interface Stock
Parameters:
si - the StockItem for which to check containment.
db - the DataBasket used to check visibility.
Override:
Never

containsStock

public boolean containsStock(Stock st,
                             DataBasket db)
Check whether the filtered Stock contains the given Stock.

Specified by:
containsStock in interface Stock
Parameters:
st - the Stock for which to check containment.
db - the DataBasket used to determine visibility.
Override:
Never

add

public void add(String sKey,
                int nCount,
                DataBasket db)
Add the specified number of items to the source Stock.

Specified by:
add in interface CountingStock
Parameters:
sKey - the key for which to add a number of items.
nCount - how many items are to be added?
db - the DataBasket relative to which the adding is performed.
Override:
Never

remove

public void remove(String sKey,
                   int nCount,
                   DataBasket db)
            throws VetoException
Remove at most the specified number of items from the source Stock. If the filtered Stock contains fewer items than specified only as many items as are contained in the filtered Stock will be removed from the source Stock.

Specified by:
remove in interface CountingStock
Parameters:
sKey - the key for which to remove a number of items.
nCount - how many items are to be removed?
db - the DataBasket relative to which the removal is performed.
Throws:
VetoException - if a listener vetos the removal.
Override:
Never

SalesPoint Framework v3.1