org.salespointframework.core.data
Class StockItemImpl

java.lang.Object
  extended by org.salespointframework.core.data.AbstractNameable
      extended by org.salespointframework.core.data.StockItemImpl
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<java.lang.Object>, Recoverable, DataBasketKeys, Nameable, SpItem, StockItem
Direct Known Subclasses:
StockImpl

public class StockItemImpl
extends AbstractNameable
implements StockItem, DataBasketKeys, Recoverable

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

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

Field Summary
(package private) static int COMMIT_ACTION
           
private  int m_id
          Unique id of item
private  StockImpl<?,?,?> m_stiOwner
          The Stock that contains this StockItem.
(package private) static int ROLLBACK_ACTION
           
(package private) static int STARTEDIT_ACTION
           
 
Fields inherited from class org.salespointframework.core.data.AbstractNameable
m_ncContext, m_pcsPropertyListeners, SOME_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
StockItemImpl(java.lang.String sName)
          Create a new StockItemImpl.
 
Method Summary
 java.lang.Object clone()
          Clone this StockItem.
 int compareTo(java.lang.Object o)
          Compare this StockItem to the given object.
 boolean equals(java.lang.Object o)
          Check whether this StockItem equals the given object.
 void firePropertyChanged()
          Signals persistence layer to update objects values
 CatalogItem getAssociatedItem(DataBasket db)
          Get the CatalogItem that is associated with this StockItem.
 StockItemImpl getShallowClone()
          Get a shallow clone of this item.
 StockImpl<?,?,?> getStock()
          Get the Stock that contains this StockItem.
(package private)  void internalSetName(java.lang.String sNewName)
          Internal communication method needed for referential integrity in StoringStocks.
 void recover(java.util.Map<java.lang.String,java.lang.Object> data, java.lang.Object recoveryContext, boolean reInit)
          Set the stock on recovery
(package private)  void relinkCatalog(DataBasket db, int nAction)
          Helper method used to maintain StockImpl - CatalogImpl links in nested Stocks/Catalogs.
protected  void setStock(StockImpl<?,?,?> sti)
          Set the Stock that contains this StockItem.
 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
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
 

Field Detail

m_stiOwner

private StockImpl<?,?,?> m_stiOwner
The Stock that contains this StockItem.


m_id

private int m_id
Unique id of item


COMMIT_ACTION

static final int COMMIT_ACTION
See Also:
Constant Field Values

ROLLBACK_ACTION

static final int ROLLBACK_ACTION
See Also:
Constant Field Values

STARTEDIT_ACTION

static final int STARTEDIT_ACTION
See Also:
Constant Field Values
Constructor Detail

StockItemImpl

public StockItemImpl(java.lang.String sName)
Create a new StockItemImpl.

Parameters:
sName - the name of the new item.
Method Detail

getStock

public StockImpl<?,?,?> getStock()
Get the Stock that contains this StockItem.

Specified by:
getStock in interface StockItem

getAssociatedItem

public CatalogItem getAssociatedItem(DataBasket db)
Get the CatalogItem that is associated with this StockItem.

If the StockItem has a Stock, the associated CatalogItem is the CatalogItem of the same name that is found in the Stock's associated Catalog. Otherwise, it is null.

Specified by:
getAssociatedItem in interface StockItem
Parameters:
db - the DataBasket used to determine visibility.

setStock

protected void setStock(StockImpl<?,?,?> sti)
Set the Stock that contains this StockItem.


clone

public java.lang.Object clone()
Clone this StockItem.

Specified by:
clone in interface StockItem
Overrides:
clone in class java.lang.Object

getShallowClone

public StockItemImpl getShallowClone()
Get a shallow clone of this item.

For a normal item, shallow and deep clones are identical, which is why the default implementation returns ((StockItemImpl) clone()). However, when making a shallow clone of a Stock, the individual StockItems will not be cloned.


equals

public boolean equals(java.lang.Object o)
Check whether this StockItem equals the given object.

Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(java.lang.Object o)
Compare this StockItem to the given object.

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

internalSetName

void internalSetName(java.lang.String sNewName)
Internal communication method needed for referential integrity in StoringStocks.

Attention: This method must not be called directly.


toString

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

Overrides:
toString in class java.lang.Object

relinkCatalog

void relinkCatalog(DataBasket db,
                   int nAction)
Helper method used to maintain StockImpl - CatalogImpl links in nested Stocks/Catalogs. For internal use only.

Parameters:
db - the DataBasket that protecting this activity.
nAction - the action that occurred. Can be either COMMIT_ACTION, ROLLBACK_ACTION, STARTEDIT_ACTION.

recover

public void recover(java.util.Map<java.lang.String,java.lang.Object> data,
                    java.lang.Object recoveryContext,
                    boolean reInit)
Set the stock on recovery

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