SalesPoint Framework v3.1

data.filters
Class CatalogFilter

java.lang.Object
  extended bydata.filters.CatalogFilter
All Implemented Interfaces:
Catalog, CatalogChangeListener, CatalogItem, Comparable, DataBasketEntryDestination, DataBasketEntrySource, EventListener, HelpableListener, ListenableCatalog, Nameable, Serializable
Direct Known Subclasses:
CurrencyFilter

public abstract class CatalogFilter
extends Object
implements Catalog, CatalogChangeListener, ListenableCatalog, HelpableListener

A filter for Catalogs.

CatalogFilters can be used to present partial views of a Catalog to parts of your application, e.g., GUI elements. However, you cannot use a CatalogFilter as a replacement for a 'real' Catalog, e.g., as an item in another Catalog.

The actual filter condition is defined by overriding method match(data.CatalogItem).

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

Field Summary
protected  Catalog m_cOrg
          The Catalog that is being filtered.
protected  ListenerHelper m_lhListeners
          The listeners that listen for events from this Catalog.
 
Fields inherited from interface data.CatalogItem
VALUE_PROPERTY
 
Fields inherited from interface data.Nameable
NAME_PROPERTY
 
Constructor Summary
CatalogFilter(Catalog cOrg)
          Create a new CatalogFilter.
 
Method Summary
 void add(CatalogItem ci, DataBasket db)
          Add the given item to the source Catalog.
 void addCatalogChangeListener(CatalogChangeListener ccl)
          Add a listener that wishes to receive events when the filtered Catalog changes.
 void addedCatalogItem(CatalogChangeEvent e)
          Translate and propagate the event to all listeners of this Catalog.
 void addNameListener(PropertyChangeListener pcl)
          Register the listener with the source Catalog.
 void addPropertyChangeListener(PropertyChangeListener pcl)
          Register the listener with the source Catalog.
 void addValueListener(PropertyChangeListener pcl)
          Register the listener with the source Catalog.
 NameContext attach(NameContext nc)
          Attach the given name context to the source Catalog.
 void canEditCatalogItem(CatalogChangeEvent e)
          Translate and propagate the event to all listeners of this Catalog.
 void canRemoveCatalogItem(CatalogChangeEvent e)
          Translate and propagate the event to all listeners of this Catalog.
 void commitedAddCatalogItem(CatalogChangeEvent e)
          Translate and propagate the event to all listeners of this Catalog.
 void commitEditCatalogItem(CatalogChangeEvent e)
          Translate and propagate the event to all listeners of this Catalog.
 void commitedRemoveCatalogItem(CatalogChangeEvent e)
          Translate and propagate the event to all listeners of this Catalog.
 int compareTo(Object o)
          Compare the source Catalog to the given object.
 boolean contains(String sKey, DataBasket db)
          Check whether the indicated item is contained in the filtered Catalog.
 NameContext detachNC()
          Detach the current name context from the source Catalog.
 void editingCatalogItem(CatalogChangeEvent e)
          Translate and propagate the event to all listeners of this Catalog.
protected  void fireCanEditCatalogItem(CatalogItem ci, DataBasket db)
          Fire the event to all listeners of this Catalog.
protected  void fireCanRemoveCatalogItem(CatalogItem ci, DataBasket db)
          Fire the event to all listeners of this Catalog.
protected  void fireCatalogItemAddCommit(CatalogItem ci, DataBasket db)
          Fire the event to all listeners of this Catalog.
protected  void fireCatalogItemAdded(CatalogItem ci, DataBasket db)
          Fire the event to all listeners of this Catalog.
protected  void fireCatalogItemAddRollback(CatalogItem ci, DataBasket db)
          Fire the event to all listeners of this Catalog.
protected  void fireCatalogItemRemoveCommit(CatalogItem ci, DataBasket db)
          Fire the event to all listeners of this Catalog.
protected  void fireCatalogItemRemoved(CatalogItem ci, DataBasket db)
          Fire the event to all listeners of this Catalog.
protected  void fireCatalogItemRemoveRollback(CatalogItem ci, DataBasket db)
          Fire the event to all listeners of this Catalog.
protected  void fireCommitEditCatalogItem(CatalogItem ci, DataBasket db)
          Fire the event to all listeners of this Catalog.
protected  void fireEditingCatalogItem(CatalogItem ci, DataBasket db)
          Fire the event to all listeners of this Catalog.
protected  void fireNoEditCatalogItem(CatalogItem ci, DataBasket db)
          Fire the event to all listeners of this Catalog.
protected  void fireNoRemoveCatalogItem(CatalogItem ci, DataBasket db)
          Fire the event to all listeners of this Catalog.
protected  void fireRollbackEditCatalogItem(CatalogItem ci, DataBasket db)
          Fire the event to all listeners of this Catalog.
 CatalogItem get(String sKey, DataBasket db, boolean fForEdit)
          Get the indicated item from the source Catalog if it is contained in the filtered Catalog.
 Catalog getCatalog()
          Get the source Catalog's Catalog.
 Catalog getMainCatalog()
          Get the source catalog.
 String getName()
          Get the source Catalog's name.
 Value getValue()
          Get the source Catalog's value.
 Iterator iterator(DataBasket db, boolean fForEdit)
          Get an iterator of all items that are contained in the filtered Catalog.
 Set keySet(DataBasket db)
          Return a set that contains all keys for which a CatalogItem is contained in the filtered Catalog.
protected abstract  boolean match(CatalogItem ci)
          Filter condition.
 void noEditCatalogItem(CatalogChangeEvent e)
          Translate and propagate the event to all listeners of this Catalog.
 void noRemoveCatalogItem(CatalogChangeEvent e)
          Translate and propagate the event to all listeners of this Catalog.
 CatalogItem remove(CatalogItem ci, DataBasket db)
          Remove the given item from the source Catalog if it is contained in the filtered Catalog.
 CatalogItem remove(String sKey, DataBasket db)
          Remove the given item from the source Catalog if it is contained in the filtered Catalog.
 void removeCatalogChangeListener(CatalogChangeListener ccl)
          Remove a listener that received events when the filtered Catalog changed.
 void removedCatalogItem(CatalogChangeEvent e)
          Translate and propagate the event to all listeners of this Catalog.
 void removeNameListener(PropertyChangeListener pcl)
          Un-Register the listener with the source Catalog.
 void removePropertyChangeListener(PropertyChangeListener pcl)
          Un-Register the listener with the source Catalog.
 void removeValueListener(PropertyChangeListener pcl)
          Un-Register the listener with the source Catalog.
 void rollbackEditCatalogItem(CatalogChangeEvent e)
          Translate and propagate the event to all listeners of this Catalog.
 void rolledbackAddCatalogItem(CatalogChangeEvent e)
          Translate and propagate the event to all listeners of this Catalog.
 void rolledbackRemoveCatalogItem(CatalogChangeEvent e)
          Translate and propagate the event to all listeners of this Catalog.
 void setName(String sName, DataBasket db)
          Set the source Catalog's name.
 int size(DataBasket db)
          Calculate the size of the filtered Catalog.
 void subscribe()
          Subscribe as a listener to the source Catalog if that is a ListenableCatalog.
 void unsubscribe()
          Un-Subscribe as a listener from the source Catalog if that is a ListenableCatalog.
 void updateModel()
          Empty method body.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_cOrg

protected Catalog m_cOrg
The Catalog that is being filtered.


m_lhListeners

protected ListenerHelper m_lhListeners
The listeners that listen for events from this Catalog.

Constructor Detail

CatalogFilter

public CatalogFilter(Catalog cOrg)
Create a new CatalogFilter.

Parameters:
cOrg - the Catalog to be filtered.
Method Detail

compareTo

public int compareTo(Object o)
Compare the source Catalog to the given object.

Specified by:
compareTo in interface Comparable
Override:
Never

detachNC

public NameContext detachNC()
Detach the current name context from the source Catalog.

Specified by:
detachNC in interface Nameable
Returns:
the previously attached NameContext, if any.
Override:
Never

attach

public NameContext attach(NameContext nc)
Attach the given name context to the source Catalog.

Specified by:
attach in interface Nameable
Parameters:
nc - the new NameContext of this Nameable object.
Returns:
the previous NameContext, if any.
Override:
Never

getName

public String getName()
Get the source Catalog's name.

Specified by:
getName in interface Nameable
Override:
Never

setName

public void setName(String sName,
                    DataBasket db)
             throws NameContextException
Set the source Catalog's name.

Specified by:
setName in interface Nameable
Parameters:
sName - the new name of the object
db - the DataBasket relative to which the operation is to be performed.
Throws:
NameContextException - if the name change was not approved of by the NameContext.
See Also:
NameContext
Override:
Never

getValue

public Value getValue()
Get the source Catalog's value.

Specified by:
getValue in interface CatalogItem
Override:
Never

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener pcl)
Register the listener with the source Catalog.

Specified by:
addPropertyChangeListener in interface Nameable
Override:
Never

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener pcl)
Un-Register the listener with the source Catalog.

Specified by:
removePropertyChangeListener in interface Nameable
Override:
Never

addNameListener

public void addNameListener(PropertyChangeListener pcl)
Register the listener with the source Catalog.

Specified by:
addNameListener in interface Nameable
Override:
Never

removeNameListener

public void removeNameListener(PropertyChangeListener pcl)
Un-Register the listener with the source Catalog.

Specified by:
removeNameListener in interface Nameable
Override:
Never

addValueListener

public void addValueListener(PropertyChangeListener pcl)
Register the listener with the source Catalog.

Specified by:
addValueListener in interface CatalogItem
Override:
Never

removeValueListener

public void removeValueListener(PropertyChangeListener pcl)
Un-Register the listener with the source Catalog.

Specified by:
removeValueListener in interface CatalogItem
Override:
Never

getCatalog

public Catalog getCatalog()
Get the source Catalog's Catalog.

Specified by:
getCatalog in interface CatalogItem
Override:
Never

getMainCatalog

public Catalog getMainCatalog()
Get the source catalog. If the source catalog is a CatalogFilter again, return this Catalog's MainCatalog.

Override:
Never

add

public void add(CatalogItem ci,
                DataBasket db)
Add the given item to the source Catalog.

Specified by:
add in interface Catalog
Parameters:
ci - the CatalogItem to be added. This item must not be contained in another Catalog.
db - the DataBasket relative to which the operation is to be performed.
Override:
Never

remove

public CatalogItem remove(CatalogItem ci,
                          DataBasket db)
                   throws VetoException
Remove the given item from the source Catalog if it is contained in the filtered Catalog.

Specified by:
remove in interface Catalog
Parameters:
ci - the CatalogItem to be removed.
db - the DataBasket relative to which the operation is to be performed.
Returns:
the item that was actually removed.
Throws:
VetoException - if one of the listeners vetos the removal.
Override:
Never

remove

public CatalogItem remove(String sKey,
                          DataBasket db)
                   throws VetoException
Remove the given item from the source Catalog if it is contained in the filtered Catalog.

Specified by:
remove in interface Catalog
Parameters:
sKey - the key of the CatalogItem to be removed.
db - the DataBasket relative to which the operation is to be performed.
Returns:
the item that was actually removed.
Throws:
VetoException - if one of the listeners vetos the removal.
Override:
Never

get

public CatalogItem get(String sKey,
                       DataBasket db,
                       boolean fForEdit)
                throws VetoException
Get the indicated item from the source Catalog if it is contained in the filtered Catalog.

Specified by:
get in interface Catalog
Parameters:
sKey - the key of the CatalogItem to be retrieved.
db - the DataBasket relative to which the operation is to be performed.
fForEdit - if true, the CatalogItem will be retrieved for editing.
Returns:
the item that is associated with the given key.
Throws:
VetoException - if one of the listeners vetos the editing.
Override:
Never

contains

public boolean contains(String sKey,
                        DataBasket db)
Check whether the indicated item is contained in the filtered Catalog.

Specified by:
contains in interface Catalog
Parameters:
sKey - the key for which to check containment.
db - the DataBasket that defines visibility of items. See Catalog.add(data.CatalogItem, data.DataBasket) and Catalog.remove(data.CatalogItem, data.DataBasket) for details on visibility.
Override:
Never

iterator

public Iterator iterator(DataBasket db,
                         boolean fForEdit)
Get an iterator of all items that are contained in the filtered Catalog.

Specified by:
iterator in interface Catalog
Parameters:
db - the DataBasket that defines visibility.
fForEdit - if true, the items are retrieved for editing. VetoException will be converted into UnsupportedOperationExceptions.
Override:
Never

keySet

public Set keySet(DataBasket db)
Return a set that contains all keys for which a CatalogItem is contained in the filtered Catalog.

Specified by:
keySet in interface Catalog
Parameters:
db - the DataBasket used to determine visibility of elements.
Override:
Never

size

public int size(DataBasket db)
Calculate the size of the filtered Catalog.

Specified by:
size in interface Catalog
Parameters:
db - the DataBasket used to determine visibility.
Override:
Never

match

protected abstract boolean match(CatalogItem ci)
Filter condition.

Parameters:
ci - the item to be tested
Returns:
true if the given item shall be an item of the filtered Catalog.
Override:
Always

addedCatalogItem

public void addedCatalogItem(CatalogChangeEvent e)
Translate and propagate the event to all listeners of this Catalog.

Specified by:
addedCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

commitedAddCatalogItem

public void commitedAddCatalogItem(CatalogChangeEvent e)
Translate and propagate the event to all listeners of this Catalog.

Specified by:
commitedAddCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

rolledbackAddCatalogItem

public void rolledbackAddCatalogItem(CatalogChangeEvent e)
Translate and propagate the event to all listeners of this Catalog.

Specified by:
rolledbackAddCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

canRemoveCatalogItem

public void canRemoveCatalogItem(CatalogChangeEvent e)
                          throws VetoException
Translate and propagate the event to all listeners of this Catalog.

Specified by:
canRemoveCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Throws:
VetoException - if the listener wants to veto the removal.
Override:
Never

noRemoveCatalogItem

public void noRemoveCatalogItem(CatalogChangeEvent e)
Translate and propagate the event to all listeners of this Catalog.

Specified by:
noRemoveCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

removedCatalogItem

public void removedCatalogItem(CatalogChangeEvent e)
Translate and propagate the event to all listeners of this Catalog.

Specified by:
removedCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

commitedRemoveCatalogItem

public void commitedRemoveCatalogItem(CatalogChangeEvent e)
Translate and propagate the event to all listeners of this Catalog.

Specified by:
commitedRemoveCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

rolledbackRemoveCatalogItem

public void rolledbackRemoveCatalogItem(CatalogChangeEvent e)
Translate and propagate the event to all listeners of this Catalog.

Specified by:
rolledbackRemoveCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

canEditCatalogItem

public void canEditCatalogItem(CatalogChangeEvent e)
                        throws VetoException
Translate and propagate the event to all listeners of this Catalog.

Specified by:
canEditCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Throws:
VetoException - if the listener wants to veto the editing.
Override:
Never

noEditCatalogItem

public void noEditCatalogItem(CatalogChangeEvent e)
Translate and propagate the event to all listeners of this Catalog.

Specified by:
noEditCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

editingCatalogItem

public void editingCatalogItem(CatalogChangeEvent e)
Translate and propagate the event to all listeners of this Catalog.

Specified by:
editingCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

commitEditCatalogItem

public void commitEditCatalogItem(CatalogChangeEvent e)
Translate and propagate the event to all listeners of this Catalog.

Specified by:
commitEditCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

rollbackEditCatalogItem

public void rollbackEditCatalogItem(CatalogChangeEvent e)
Translate and propagate the event to all listeners of this Catalog.

Specified by:
rollbackEditCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

addCatalogChangeListener

public void addCatalogChangeListener(CatalogChangeListener ccl)
Add a listener that wishes to receive events when the filtered Catalog changes.

Specified by:
addCatalogChangeListener in interface ListenableCatalog
Parameters:
ccl - the listener to be added.
Override:
Never

removeCatalogChangeListener

public void removeCatalogChangeListener(CatalogChangeListener ccl)
Remove a listener that received events when the filtered Catalog changed.

Specified by:
removeCatalogChangeListener in interface ListenableCatalog
Parameters:
ccl - the listener to be removed.
Override:
Never

fireCatalogItemAdded

protected void fireCatalogItemAdded(CatalogItem ci,
                                    DataBasket db)
Fire the event to all listeners of this Catalog.

Override:
Never

fireCatalogItemAddCommit

protected void fireCatalogItemAddCommit(CatalogItem ci,
                                        DataBasket db)
Fire the event to all listeners of this Catalog.

Override:
Never

fireCatalogItemAddRollback

protected void fireCatalogItemAddRollback(CatalogItem ci,
                                          DataBasket db)
Fire the event to all listeners of this Catalog.

Override:
Never

fireCatalogItemRemoved

protected void fireCatalogItemRemoved(CatalogItem ci,
                                      DataBasket db)
Fire the event to all listeners of this Catalog.

Override:
Never

fireCatalogItemRemoveCommit

protected void fireCatalogItemRemoveCommit(CatalogItem ci,
                                           DataBasket db)
Fire the event to all listeners of this Catalog.

Override:
Never

fireCatalogItemRemoveRollback

protected void fireCatalogItemRemoveRollback(CatalogItem ci,
                                             DataBasket db)
Fire the event to all listeners of this Catalog.

Override:
Never

fireCanRemoveCatalogItem

protected void fireCanRemoveCatalogItem(CatalogItem ci,
                                        DataBasket db)
                                 throws VetoException
Fire the event to all listeners of this Catalog.

Throws:
VetoException
Override:
Never

fireNoRemoveCatalogItem

protected void fireNoRemoveCatalogItem(CatalogItem ci,
                                       DataBasket db)
Fire the event to all listeners of this Catalog.

Override:
Never

fireCanEditCatalogItem

protected void fireCanEditCatalogItem(CatalogItem ci,
                                      DataBasket db)
                               throws VetoException
Fire the event to all listeners of this Catalog.

Throws:
VetoException
Override:
Never

fireNoEditCatalogItem

protected void fireNoEditCatalogItem(CatalogItem ci,
                                     DataBasket db)
Fire the event to all listeners of this Catalog.

Override:
Never

fireEditingCatalogItem

protected void fireEditingCatalogItem(CatalogItem ci,
                                      DataBasket db)
Fire the event to all listeners of this Catalog.

Override:
Never

fireCommitEditCatalogItem

protected void fireCommitEditCatalogItem(CatalogItem ci,
                                         DataBasket db)
Fire the event to all listeners of this Catalog.

Override:
Never

fireRollbackEditCatalogItem

protected void fireRollbackEditCatalogItem(CatalogItem ci,
                                           DataBasket db)
Fire the event to all listeners of this Catalog.

Override:
Never

subscribe

public void subscribe()
Subscribe as a listener to the source Catalog if that is a ListenableCatalog.

Specified by:
subscribe in interface HelpableListener
Override:
Never

unsubscribe

public void unsubscribe()
Un-Subscribe as a listener from the source Catalog if that is a ListenableCatalog.

Specified by:
unsubscribe in interface HelpableListener
Override:
Never

updateModel

public void updateModel()
Empty method body.

Specified by:
updateModel in interface HelpableListener
Override:
Never

SalesPoint Framework v3.1