public final class PortfolioDAO extends Object
Portfolio
objects
from the datastore.Constructor and Description |
---|
PortfolioDAO() |
Modifier and Type | Method and Description |
---|---|
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.
|
public PortfolioDAO()
public void saveAs(Portfolio aPortfolio)
isValidCandidateName(java.lang.String)
to
verify that a candidate name does not already exist.aPortfolio
- has a name different from any known Portfolio.public void save(Portfolio aPortfolio)
saveAs(hirondelle.stocks.portfolio.Portfolio)
must be used if aPortfolio has not yet been saved.aPortfolio
- already exists in storage.public void saveAsDefault(Portfolio aPortfolio)
public Portfolio fetchDefaultPortfolio()
public Collection<String> fetchAllPortfolioNames()
The iteration order of the return value is alphabetical.
public boolean isValidCandidateName(String aNewName)
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.
public Portfolio fetch(String aPortfolioName)
aPortfolioName
- must be known to the datastore.public void delete(Portfolio aPortfolio)
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()
.
public void deleteAll()
End users can only delete Portfolios one at at time, using
delete(hirondelle.stocks.portfolio.Portfolio)
.
public void exportXML(File aFile)
Preferences.exportSubtree(java.io.OutputStream)
.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.public void importXML(File aFile)
exportXML(java.io.File)
.aFile
- must already exist, must have read access, and must contain an
unmodified result of exportXML(java.io.File)
.Copyright Hirondelle Systems - License - Generated 2013Sep20.10.58