SalesPoint Framework v3.1

data
Interface Nameable

All Superinterfaces:
Serializable
All Known Subinterfaces:
Catalog, CatalogItem, CountingStock, Currency, CurrencyItem, ListenableCatalog, ListenableStock, MoneyBag, Stock, StockItem, StoringStock
All Known Implementing Classes:
AbstractCurrency, AbstractNameable, AbstractStockFilter, CatalogFilter, CatalogImpl, CatalogItemImpl, CountingStockFilter, CountingStockImpl, CurrencyFilter, CurrencyImpl, CurrencyItemImpl, MoneyBagFilter, MoneyBagImpl, StockImpl, StockItemImpl, StoringStockFilter, StoringStockImpl

public interface Nameable
extends Serializable

An object that has a name that complies with a NameContext's rules.

When implementing nameable objects you migth want to subclass AbstractNameable, which already implements all the methods required by Nameable.

Since:
v2.0
Author:
Steffen Zschaler
See Also:
Catalog, Stock, CatalogItem, NameContext

Field Summary
static String NAME_PROPERTY
          The programmatical name of the "name" property.
 
Method Summary
 void addNameListener(PropertyChangeListener pcl)
          Add a PropertyChangeListener that will receive events whenever the "name" property changes.
 void addPropertyChangeListener(PropertyChangeListener pcl)
          Register a listener to receive events whenever propertiy changes.
 NameContext attach(NameContext nc)
          Attach a NameContext to this Nameable.
 NameContext detachNC()
          Detach the current NameContext from this Nameable.
 String getName()
          Get the name of this Nameable object.
 void removeNameListener(PropertyChangeListener pcl)
          Remove a PropertyChangeListener for the "name" property.
 void removePropertyChangeListener(PropertyChangeListener pcl)
          Stop a listener from receiving events whenever a property changes.
 void setName(String sName, DataBasket db)
          Set the Nameable's name.
 

Field Detail

NAME_PROPERTY

public static final String NAME_PROPERTY
The programmatical name of the "name" property. This is "name".

See Also:
Constant Field Values
Method Detail

attach

public NameContext attach(NameContext nc)
Attach a NameContext to this Nameable.

No naming conventions are checked neither in the old nor in the new NameContext.

Parameters:
nc - the new NameContext of this Nameable object.
Returns:
the previous NameContext, if any.
Override:
Always

detachNC

public NameContext detachNC()
Detach the current NameContext from this Nameable.

Returns:
the previously attached NameContext, if any.
Override:
Always

setName

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

setName() must implement the following protocol (Let nc be the Nameable's current NameContext):

 if (nc != null) {
   synchronized (nc.getNCMonitor()) {
     nc.checkNameChange (db, getName(), sName);

     // set the internal name attribute(s), leaving old name in sOldName

     nc.nameHasChanged (db, sOldName, getName());
   }
 }
 else {
   // set the internal name attribute(s)
 }
 

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:
Always

getName

public String getName()
Get the name of this Nameable object.

Override:
Always

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener pcl)
Register a listener to receive events whenever propertiy changes.

Override:
Always

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener pcl)
Stop a listener from receiving events whenever a property changes.

Override:
Always

addNameListener

public void addNameListener(PropertyChangeListener pcl)
Add a PropertyChangeListener that will receive events whenever the "name" property changes.

Override:
Always

removeNameListener

public void removeNameListener(PropertyChangeListener pcl)
Remove a PropertyChangeListener for the "name" property.

Override:
Always

SalesPoint Framework v3.1