org.salespointframework.core.data
Class CatalogItemImpl

java.lang.Object
  extended by org.salespointframework.core.data.AbstractNameable
      extended by org.salespointframework.core.data.CatalogItemImpl
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<java.lang.Object>, Recoverable, CatalogItem, DataBasketKeys, Nameable, SpItem
Direct Known Subclasses:
CatalogImpl, CurrencyItemImpl

public abstract class CatalogItemImpl
extends AbstractNameable
implements CatalogItem, DataBasketKeys, java.lang.Cloneable, Recoverable

Pure Java implementation of the CatalogItem interface. See the documentation for CatalogItem for a description of the semantics of this class.

Since:
v2.0
Version:
2.0 19/08/1999
Author:
Steffen Zschaler

Field Summary
 
Fields inherited from class org.salespointframework.core.data.AbstractNameable
m_ncContext, m_pcsPropertyListeners, SOME_PROPERTY
 
Fields inherited from interface org.salespointframework.core.data.interfaces.CatalogItem
VALUE_PROPERTY
 
Fields inherited from interface org.salespointframework.core.data.interfaces.Nameable
NAME_PROPERTY
 
Fields inherited from interface org.salespointframework.core.data.interfaces.DataBasketKeys
CATALOG_ITEM_MAIN_KEY, STOCK_ITEM_MAIN_KEY
 
Constructor Summary
CatalogItemImpl(java.lang.String sName)
          Create a new CatalogItemImpl.
CatalogItemImpl(java.lang.String sName, Value vValue)
          Create a new CatalogItemImpl.
CatalogItemImpl(java.lang.String sName, Value vValue, java.net.URI imagefile)
          Create a new CatalogItemImpl.
 
Method Summary
 void addValueListener(java.beans.PropertyChangeListener pcl)
          Add a PropertyChangeListener that will receive events whenever the "value" property changes.
 int compareTo(java.lang.Object o)
          Compare this CatalogItem to an object.
 boolean equals(java.lang.Object o)
          Check whether two objects are equal.
 void firePropertyChanged()
          Signals persistence layer to update objects values
 Catalog getCatalog()
          Get the Catalog of this CatalogItem.
 java.awt.image.BufferedImage getImage()
          Get the image of the CatalogItem
protected  byte[] getImageBytes()
          retrieve image data as byte array
protected
<T extends CatalogItemImpl>
T
getInternalShallowClone()
          Get a shallow clone of the CatalogItem.
protected abstract  CatalogItemImpl getShallowClone()
          Get a shallow clone of the CatalogItem.
 Value getValue()
          Get the item's value.
 boolean isEditable()
          Return true if this CatalogItem is editable.
 void recover(java.util.Map<java.lang.String,java.lang.Object> data, java.lang.Object recoveryContext, boolean reInit)
          Recover owner and context
 void removeValueListener(java.beans.PropertyChangeListener pcl)
          Remove a PropertyChangeListener for the "value" property.
 boolean setImage(java.net.URI filename)
          Set the image of the CatalogItem for performance reason, you have to call firePropertyChanged() separately
protected  void setImageBytes(byte[] data)
          set image bytes and invalidate image cache
protected  void setValue(Value vNew)
          Set the item's value.
 java.lang.String toString()
          Return a String representation of the item.
 
Methods inherited from class org.salespointframework.core.data.AbstractNameable
addNameListener, addPropertyChangeListener, attach, detachNC, getName, removeNameListener, removePropertyChangeListener, setName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.salespointframework.core.data.interfaces.Nameable
addNameListener, addPropertyChangeListener, attach, detachNC, getName, removeNameListener, removePropertyChangeListener, setName
 
Methods inherited from interface org.salespointframework.core.data.interfaces.SpItem
getName
 

Constructor Detail

CatalogItemImpl

public CatalogItemImpl(java.lang.String sName)
Create a new CatalogItemImpl. The item's value defaults to an IntegerValue of 0.

Parameters:
sName - the name of the new item.

CatalogItemImpl

public CatalogItemImpl(java.lang.String sName,
                       Value vValue)
Create a new CatalogItemImpl.

Parameters:
sName - the name of the new item.
vValue - the value of the item.

CatalogItemImpl

public CatalogItemImpl(java.lang.String sName,
                       Value vValue,
                       java.net.URI imagefile)
Create a new CatalogItemImpl.

Parameters:
sName - the name of the new item.
vValue - the value of the item.
imagefile - uri to imagefile
Method Detail

setImage

public boolean setImage(java.net.URI filename)
Set the image of the CatalogItem for performance reason, you have to call firePropertyChanged() separately

Specified by:
setImage in interface CatalogItem
Parameters:
filename - uri, pointing to the image file
Returns:
true on success

getImage

public java.awt.image.BufferedImage getImage()
Get the image of the CatalogItem

Specified by:
getImage in interface CatalogItem
Returns:
the image, or null if no image set

getImageBytes

protected byte[] getImageBytes()
retrieve image data as byte array

Returns:
image bytes

setImageBytes

protected void setImageBytes(byte[] data)
set image bytes and invalidate image cache

Parameters:
data - new image as byte array

getValue

public Value getValue()
Get the item's value.

Specified by:
getValue in interface CatalogItem
Returns:
a clone of the item's value.

setValue

protected void setValue(Value vNew)
Set the item's value. This method is protected so that subclasses can decide whether or not to allow clients to set the value of a CatalogItem once it has been created.

The method will fire a property change event for the "value" property.


isEditable

public boolean isEditable()
Return true if this CatalogItem is editable.


getCatalog

public Catalog getCatalog()
Get the Catalog of this CatalogItem.

Specified by:
getCatalog in interface CatalogItem

toString

public java.lang.String toString()
Return a String representation of the item.

Overrides:
toString in class java.lang.Object

getShallowClone

protected abstract CatalogItemImpl getShallowClone()
Get a shallow clone of the CatalogItem. For normal CatalogItems there is no difference between a shallow and a deep clone.


getInternalShallowClone

protected <T extends CatalogItemImpl> T getInternalShallowClone()
Get a shallow clone of the CatalogItem. This is for internal use only.


compareTo

public int compareTo(java.lang.Object o)
Compare this CatalogItem to an object.

Specified by:
compareTo in interface java.lang.Comparable<java.lang.Object>
Throws:
java.lang.ClassCastException - if the given object cannot be cast into a CatalogItem.

equals

public boolean equals(java.lang.Object o)
Check whether two objects are equal.

Overrides:
equals in class java.lang.Object

addValueListener

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

Specified by:
addValueListener in interface CatalogItem

removeValueListener

public void removeValueListener(java.beans.PropertyChangeListener pcl)
Remove a PropertyChangeListener for the "value" property.

Specified by:
removeValueListener in interface CatalogItem

recover

public void recover(java.util.Map<java.lang.String,java.lang.Object> data,
                    java.lang.Object recoveryContext,
                    boolean reInit)
Recover owner and context

Specified by:
recover in interface Recoverable
Parameters:
data - field to value mapping
reInit - true, id recover was called more than one time on this object

firePropertyChanged

public void firePropertyChanged()
Signals persistence layer to update objects values

Specified by:
firePropertyChanged in interface CatalogItem