StocksMonitor 1.5.0

hirondelle.stocks.portfolio
Class CurrentPortfolio

Object
  extended by Observable
      extended by CurrentPortfolio

public final class CurrentPortfolio
extends Observable

The central abstraction of this package, representing the current selection of stocks of interest to the end user (a Portfolio).

CurrentPortfolio may be used as an example implementation for any application which edits items one at a time.

The isUntitled() and getNeedsSave() properties are particularly significant. They influence the file menu actions. For example, a CurrentPortfolio for which isUntitled() is true cannot be deleted.

CurrentPortfolio is an Observable. To minimize spurious updates, related Observer objects need to call Observable.notifyObservers() explicitly. This is important in this application, since quotes are fetched from the web each time the current portfolio is updated, and this is a relatively expensive operation.


Nested Class Summary
static class CurrentPortfolio.NeedsSave
          Enumeration for the two states of aNeedsSave passed to the constructor.
 
Constructor Summary
CurrentPortfolio(Portfolio aPortfolio, CurrentPortfolio.NeedsSave aNeedsSave)
          Constructor.
 
Method Summary
 void clear()
          Revert to an untitled Portfolio which does not need a save.
 String getName()
          Return the name of this CurrentPortfolio.
 boolean getNeedsSave()
          Return true only if this CurrentPortfolio has unsaved edits.
 Portfolio getPortfolio()
          Return the Portfolio of current interest to the user.
 Set<Stock> getStocks()
          Return the Stock objects in this CurrentPortfolio.
 boolean isUntitled()
          Return true only if the current Portfolio has never been saved under a user-specified name, neither in this session, nor in any other.
 void setName(String aName)
          Change the name of this CurrentPortfolio.
 void setNeedsSave(boolean aNeedsSave)
          Indicate that this CurrentPortfolio either does or does not have any unsaved edits.
 void setPortfolio(Portfolio aPortfolio)
          Change the Portfolio of current interest to the user.
 void setStocks(Set<Stock> aStocks)
          Change the stocks in this CurrentPortfolio.
 
Methods inherited from class Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CurrentPortfolio

public CurrentPortfolio(Portfolio aPortfolio,
                        CurrentPortfolio.NeedsSave aNeedsSave)
Constructor.

Parameters:
aPortfolio - is the set of stocks of current interest to the user; no defensive copy is made of aPortfolio.
aNeedsSave - is true only if this CurrentPortfolio has been edited by the end user, and these edits have not yet been saved.
Method Detail

clear

public void clear()
Revert to an untitled Portfolio which does not need a save.


isUntitled

public boolean isUntitled()
Return true only if the current Portfolio has never been saved under a user-specified name, neither in this session, nor in any other. Such a Portfolio appears as untitled in the display.


getPortfolio

public Portfolio getPortfolio()
Return the Portfolio of current interest to the user.


setPortfolio

public void setPortfolio(Portfolio aPortfolio)
Change the Portfolio of current interest to the user.


getName

public String getName()
Return the name of this CurrentPortfolio.


setName

public void setName(String aName)
Change the name of this CurrentPortfolio.

Parameters:
aName - has the same conditions as Portfolio.setName(String).

getStocks

public Set<Stock> getStocks()
Return the Stock objects in this CurrentPortfolio.


setStocks

public void setStocks(Set<Stock> aStocks)
Change the stocks in this CurrentPortfolio.

Parameters:
aStocks - has the same conditions as Portfolio.setStocks(Set)

getNeedsSave

public boolean getNeedsSave()
Return true only if this CurrentPortfolio has unsaved edits.


setNeedsSave

public void setNeedsSave(boolean aNeedsSave)
Indicate that this CurrentPortfolio either does or does not have any unsaved edits.


StocksMonitor 1.5.0

Copyright Hirondelle Systems - License - Generated 2008Jul12.10.53