org.salespointframework.core.data
Class AbstractNameable

java.lang.Object
  extended by org.salespointframework.core.data.AbstractNameable
All Implemented Interfaces:
Nameable
Direct Known Subclasses:
CatalogItemImpl, StockItemImpl

public abstract class AbstractNameable
extends java.lang.Object
implements Nameable

Convenience class implementing the Nameable interface.

You should derive all your Nameable classes from this class, as it provides a complete implementation of the Nameable interface. However, there is no obligation to derive from this class, as long as your class implements Nameable and sticks to the contract defined in that interface.

Since:
v2.0
Version:
2.0 25/05/1999
Author:
Steffen Zschaler

Field Summary
protected  NameContext m_ncContext
          The current name context.
private  java.lang.Object m_oNCLock
          The monitor synchronizing access to the NameContext.
protected  java.beans.PropertyChangeSupport m_pcsPropertyListeners
          Used to fire PropertyChangeEvents.
private  java.lang.String m_sName
          The name of this object.
static java.lang.String SOME_PROPERTY
          Indicates that one or more properties changed
 
Fields inherited from interface org.salespointframework.core.data.interfaces.Nameable
NAME_PROPERTY
 
Constructor Summary
AbstractNameable()
          Initialize a new AbstractNameable object with a null name.
AbstractNameable(java.lang.String sName)
          Initialize a new AbstractNameable object with the given name.
 
Method Summary
 void addNameListener(java.beans.PropertyChangeListener pcl)
          Add a PropertyChangeListener that will receive events whenever the "name" property changes.
 void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
          Add a PropertyChangeListener that will receive events whenever a bound property changes.
 NameContext attach(NameContext nc)
          Attach a NameContext to this Nameable.
 NameContext detachNC()
          Detach the current NameContext from this Nameable.
 java.lang.String getName()
          Get the name of the object.
private  java.lang.Object getNCLock()
          Return the monitor synchronizing access to the NameContext.
 void removeNameListener(java.beans.PropertyChangeListener pcl)
          Remove a PropertyChangeListener for the "name" property.
 void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
          Remove a PropertyChangeListener.
 void setName(java.lang.String sName, DataBasket db)
          Set the Nameable's name, using help by the NameContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOME_PROPERTY

public static final java.lang.String SOME_PROPERTY
Indicates that one or more properties changed

See Also:
Constant Field Values

m_pcsPropertyListeners

protected java.beans.PropertyChangeSupport m_pcsPropertyListeners
Used to fire PropertyChangeEvents.


m_sName

private java.lang.String m_sName
The name of this object.


m_ncContext

protected NameContext m_ncContext
The current name context.


m_oNCLock

private transient java.lang.Object m_oNCLock
The monitor synchronizing access to the NameContext.

Constructor Detail

AbstractNameable

public AbstractNameable()
Initialize a new AbstractNameable object with a null name.


AbstractNameable

public AbstractNameable(java.lang.String sName)
Initialize a new AbstractNameable object with the given name. The name context will initially be null.

Parameters:
sName - the AbstractNameable's name.
Method Detail

getNCLock

private final java.lang.Object getNCLock()
Return the monitor synchronizing access to the NameContext.


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.

All access to the NameContext is synchronized for thread-safety.

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

detachNC

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

All access to the NameContext is synchronized for thread-safety.

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

setName

public void setName(java.lang.String sName,
                    DataBasket db)
             throws NameContextException
Set the Nameable's name, using help by the NameContext.

All access to the NameContext is synchronized for thread-safety.

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

getName

public java.lang.String getName()
Get the name of the object. override Never

Specified by:
getName in interface Nameable

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
Add a PropertyChangeListener that will receive events whenever a bound property changes.

Specified by:
addPropertyChangeListener in interface Nameable

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
Remove a PropertyChangeListener.

Specified by:
removePropertyChangeListener in interface Nameable

addNameListener

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

Specified by:
addNameListener in interface Nameable

removeNameListener

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

Specified by:
removeNameListener in interface Nameable