celeboss.data
Class ShareBlock

java.lang.Object
  extended byceleboss.data.ShareBlock
All Implemented Interfaces:
java.util.EventListener, Monitorable, java.beans.PropertyChangeListener, java.io.Serializable
Direct Known Subclasses:
PurchasedShares

public class ShareBlock
extends java.lang.Object
implements Monitorable, java.beans.PropertyChangeListener, java.io.Serializable

Class represents ablock of sharesin a single Celebrity. The classes reacts automatically to changes in price or dividend.

See Also:
Serialized Form

Field Summary
static java.lang.String CELEBRITY
          Property name for celebrity name
static java.lang.String NUMBEROFSHARES
          Property name for number of Shares
static java.lang.String PREDICTEDDIV
          Property name for number of estimated
static java.lang.String PREDICTEDVALUE
          Property name for number of estimated
static java.lang.String PURCHASED
          Property name for purchased date
 
Constructor Summary
protected ShareBlock(ShareOwner parent, Celebrity celeb)
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener arg0)
          Add a new property listener.
protected  void calculatePredictedDividend()
          Calculate the estimate divided based on number of share and when they were purchased.
protected  void calculatePredictedValue()
          Calculate predicted worth based on shares and predicted price
protected  void firePropertyChange(java.lang.String property, java.lang.Object oldValue, java.lang.Object newValue)
          Fire a change to any listeners that are registered
 Celebrity getCelebrity()
          Get the celebrity of this block.
 int getNumberOfShares()
          The number of shares.
 ShareOwner getOwner()
          Get the Portfolio owning this share block.
 java.lang.Float getPredictedDividend()
          Return the estimated dividend based on the number of shares and the number of days owned.
 java.lang.Float getPredictedValue()
          Get the predicted value of this Share block at end of trading week
 java.util.Date getPurchased()
          What date were these purchased
 void init()
          THis method is called to initialise the entity once the complete and has either been accepted by the Portfolio or when the Celebrity model has been loaded.
 void propertyChange(java.beans.PropertyChangeEvent arg0)
          Change has occured
 void release()
          This share block is no logner needed.
 void removePropertyChangeListener(java.beans.PropertyChangeListener arg0)
          Remove an existing property listener.
protected  void setNumberOfShares(int number)
          Update the number of shares in this Celebrity.
 void setPurchased(java.util.Date date)
          Update teh date these were purchased.
 java.lang.String toString()
          Return a descriptive text
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CELEBRITY

public static final java.lang.String CELEBRITY
Property name for celebrity name

See Also:
Constant Field Values

NUMBEROFSHARES

public static final java.lang.String NUMBEROFSHARES
Property name for number of Shares

See Also:
Constant Field Values

PREDICTEDDIV

public static final java.lang.String PREDICTEDDIV
Property name for number of estimated

See Also:
Constant Field Values

PREDICTEDVALUE

public static final java.lang.String PREDICTEDVALUE
Property name for number of estimated

See Also:
Constant Field Values

PURCHASED

public static final java.lang.String PURCHASED
Property name for purchased date

See Also:
Constant Field Values
Constructor Detail

ShareBlock

protected ShareBlock(ShareOwner parent,
                     Celebrity celeb)
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener arg0)
Add a new property listener.

Specified by:
addPropertyChangeListener in interface Monitorable
Parameters:
arg0 - Listener

calculatePredictedDividend

protected void calculatePredictedDividend()
Calculate the estimate divided based on number of share and when they were purchased.


calculatePredictedValue

protected void calculatePredictedValue()
Calculate predicted worth based on shares and predicted price


getCelebrity

public Celebrity getCelebrity()
Get the celebrity of this block.

Returns:
Celebtiry object.

getNumberOfShares

public int getNumberOfShares()
The number of shares.

Returns:
Integer of share number.

getOwner

public ShareOwner getOwner()
Get the Portfolio owning this share block.

Returns:
Portfolio entity

getPredictedDividend

public java.lang.Float getPredictedDividend()
Return the estimated dividend based on the number of shares and the number of days owned.

Returns:
Money value.

getPredictedValue

public java.lang.Float getPredictedValue()
Get the predicted value of this Share block at end of trading week

Returns:
Money value

getPurchased

public java.util.Date getPurchased()
What date were these purchased

Returns:
Purchase date.

init

public void init()
THis method is called to initialise the entity once the complete and has either been accepted by the Portfolio or when the Celebrity model has been loaded.


propertyChange

public void propertyChange(java.beans.PropertyChangeEvent arg0)
Change has occured

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
arg0 - Event describing change.

release

public void release()
This share block is no logner needed.


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener arg0)
Remove an existing property listener.

Specified by:
removePropertyChangeListener in interface Monitorable
Parameters:
arg0 - Listener

setNumberOfShares

protected void setNumberOfShares(int number)
Update the number of shares in this Celebrity.

Parameters:
number - New number of shares

setPurchased

public void setPurchased(java.util.Date date)
Update teh date these were purchased.

Parameters:
date - New date.

toString

public java.lang.String toString()
Return a descriptive text

Returns:
String
See Also:
Object.toString()

firePropertyChange

protected void firePropertyChange(java.lang.String property,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)
Fire a change to any listeners that are registered

Parameters:
property - Name of property changed
oldValue - Old property value, maybe null.
newValue - New property value.