StocksMonitor 1.5.0

hirondelle.stocks.portfolio
Class PortfolioDAO

Object
  extended by PortfolioDAO

public final class PortfolioDAO
extends Object

Add, change, delete, and fetch Portfolio objects from the datastore.


Constructor Summary
PortfolioDAO()
           
 
Method Summary
 void delete(Portfolio aPortfolio)
          Remove a stored Portfolio, and leave all others intact.
 void deleteAll()
          Remove all Portfolios, and start from scratch (for development purposes only).
 void exportXML(File aFile)
          Place the content of all Portfolios in a single text file, in the format defined by Preferences.exportSubtree(java.io.OutputStream).
 Portfolio fetch(String aPortfolioName)
          Return the Portfolio whose unique id is aPortfolioName.
 Collection<String> fetchAllPortfolioNames()
          Return String objects, one for each stored Portfolio.
 Portfolio fetchDefaultPortfolio()
          Used at startup, and returns the Portfolio which was current when the application was last closed.
 void importXML(File aFile)
          Replace all current Portfolios with the contents of a single XML file produced by exportXML(java.io.File).
 boolean isValidCandidateName(String aNewName)
          Return true only if aNewName has visible content and is not an element of fetchAllPortfolioNames().
 void save(Portfolio aPortfolio)
          Save a Portfolio which already exists in storage.
 void saveAs(Portfolio aPortfolio)
          Save a Portfolio under a name which is not already known to the datastore.
 void saveAsDefault(Portfolio aPortfolio)
          Save aPortfolio as the one to be launched upon startup.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PortfolioDAO

public PortfolioDAO()
Method Detail

saveAs

public void saveAs(Portfolio aPortfolio)
Save a Portfolio under a name which is not already known to the datastore. The Portfolio may be new, or may be an old Portfolio being saved under a new name. Should be used with isValidCandidateName(java.lang.String) to verify that a candidate name does not already exist.

Parameters:
aPortfolio - has a name different from any known Portfolio.

save

public void save(Portfolio aPortfolio)
Save a Portfolio which already exists in storage. saveAs(hirondelle.stocks.portfolio.Portfolio) must be used if aPortfolio has not yet been saved.

Parameters:
aPortfolio - already exists in storage.

saveAsDefault

public void saveAsDefault(Portfolio aPortfolio)
Save aPortfolio as the one to be launched upon startup.


fetchDefaultPortfolio

public Portfolio fetchDefaultPortfolio()
Used at startup, and returns the Portfolio which was current when the application was last closed. If the application was not launched before, or if an untitled Portfolio was current when it was last closed, then return an untitled Portfolio.


fetchAllPortfolioNames

public Collection<String> fetchAllPortfolioNames()
Return String objects, one for each stored Portfolio.

The iteration order of the return value is alphabetical.


isValidCandidateName

public boolean isValidCandidateName(String aNewName)
Return true only if aNewName has visible content and is not an element of fetchAllPortfolioNames().

A candidate name is a name input by the end user during a File->New or File->SaveAs operation as a candidate Portfolio name.


fetch

public Portfolio fetch(String aPortfolioName)
Return the Portfolio whose unique id is aPortfolioName.

Parameters:
aPortfolioName - must be known to the datastore.

delete

public void delete(Portfolio aPortfolio)
Remove a stored Portfolio, and leave all others intact.

If aPortfolio is the default Portfolio, then the preference for the default Portfolio is removed as well, and an untitled Portfolio will be returned from fetchDefaultPortfolio().


deleteAll

public void deleteAll()
Remove all Portfolios, and start from scratch (for development purposes only).

End users can only delete Portfolios one at at time, using delete(hirondelle.stocks.portfolio.Portfolio).


exportXML

public void exportXML(File aFile)
Place the content of all Portfolios in a single text file, in the format defined by Preferences.exportSubtree(java.io.OutputStream).

Parameters:
aFile - may or may not currently exist; if it does not yet exist, it is created; if it does exist, it must have write access, and will be overwritten by this method.

importXML

public void importXML(File aFile)
Replace all current Portfolios with the contents of a single XML file produced by exportXML(java.io.File).

Parameters:
aFile - must already exist, must have read access, and must contain an unmodified result of exportXML(java.io.File).

StocksMonitor 1.5.0

Copyright Hirondelle Systems - License - Generated 2008Jul12.10.53