|
StocksMonitor 1.5.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
ObjectObservable
CurrentPortfolio
public final class CurrentPortfolio
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 |
|---|
public CurrentPortfolio(Portfolio aPortfolio,
CurrentPortfolio.NeedsSave aNeedsSave)
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 |
|---|
public void clear()
public boolean isUntitled()
public Portfolio getPortfolio()
Portfolio of current interest to the user.
public void setPortfolio(Portfolio aPortfolio)
Portfolio of current interest to the user.
public String getName()
public void setName(String aName)
aName - has the same conditions as
Portfolio.setName(String).public Set<Stock> getStocks()
Stock objects in this
CurrentPortfolio.
public void setStocks(Set<Stock> aStocks)
aStocks - has the same conditions as
Portfolio.setStocks(Set)public boolean getNeedsSave()
public void setNeedsSave(boolean aNeedsSave)
|
StocksMonitor 1.5.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||