Venice 0.7beta

org.mov.prefs
Class PreferencesManager

java.lang.Object
  extended by org.mov.prefs.PreferencesManager

public class PreferencesManager
extends java.lang.Object

The Preferences Manager contains a set of routines for loading and saving all preferences data for the application. Consolidating these routines in a single place allows us to maintain preferences namespace convention and also allows us to easily change the method of storage at a later date if desired.

If a save method first clears all preferences data from a node, it is imperative that both the save and the equivalent load methods are synchronized. Otherwise there is the possibility the load call is called just after the delete call which would nuke all the values. Perhaps all the methods should be synchronized.

Author:
Daniel Makovec

Nested Class Summary
 class PreferencesManager.DatabasePreferences
          Database preferences fields.
 class PreferencesManager.DisplayPreferences
          Display preferences fields.
 class PreferencesManager.IDQuoteSyncPreferences
          Intra-day Quote Sync preferences fields.
 class PreferencesManager.ProxyPreferences
          Web proxy preferences fields.
 
Field Summary
static int DATABASE
          Indicates the quote source is accessing quotes in a database
static int FILES
          Deprecated. Indicates the quote source is accessing quotes in files.
static int INTERNAL
          Indicates the quote source is accessing the internal database
static int SAMPLES
          Indicates the quote source is using the inbuilt sample quotes.
 
Method Summary
static void deletePortfolio(java.lang.String name)
          Delete the portfolio.
static void deleteWatchScreen(java.lang.String name)
          Delete the watch screen.
static void flush()
          Forces the preferences data to be saved to the backend store (e.g. disk).
static java.util.HashMap getAnalyserPageSettings(java.lang.String key)
          Load all saved user input in an Analyser Page.
static PreferencesManager.DatabasePreferences getDatabaseSettings()
          Load database settings.
static java.lang.String getDefaultChart()
          Load default chart setting.
static java.lang.String getDirectoryLocation(java.lang.String dirtype)
          Load the last directory used when importing quote files.
static PreferencesManager.DisplayPreferences getDisplaySettings()
          Load display settings.
static boolean getHasGPLAcceptance()
          Return whether we require the user to explicitly accept the GPL license.
static PreferencesManager.IDQuoteSyncPreferences getIDQuoteSyncPreferences()
          Load intra-day quote sync module preferences.
static java.lang.String getInternalFileName()
          Load the file name to store the internal database.
static java.lang.String getLanguageCode()
          Load language setting.
static int getLastPreferencesPage()
          Load the last preferences page visited.
static int getMaxDecimalDigits()
          Load user interface setting.
static int getMaximumCachedQuotes()
          Load the cache's maximum number of quotes.
static int getMinDecimalDigits()
          Load user interface setting.
static Portfolio getPortfolio(java.lang.String portfolioName)
          Load the portfolio with the given name.
static java.util.List getPortfolioNames()
          Return a list of the names of all the portfolios.
static PreferencesManager.ProxyPreferences getProxySettings()
          Load proxy settings.
static int getQuoteSource()
          Get quote source setting.
static java.util.List getStoredExpressions()
          Load the list of all stored expressions.
static java.util.List getStoredMacros()
          Load the list of all registered macros.
static java.util.prefs.Preferences getUserNode(java.lang.String node)
          Fetches the desired user node, based at the base branch
static java.lang.String getUserNotes(java.lang.String symbol)
           
static WatchScreen getWatchScreen(java.lang.String name)
          Load the watch screen with the given name.
static java.util.List getWatchScreenNames()
          Return a list of the names of all the watch screens.
static void putAnalyserPageSettings(java.lang.String key, java.util.HashMap settings)
          Save all user input in an Analyser Page.
static void putDatabaseSettings(PreferencesManager.DatabasePreferences databasePreferences)
          Save database settings.
static void putDefaultChart(java.lang.String defaultChart)
          Save default chart setting.
static void putDirectoryLocation(java.lang.String dirtype, java.lang.String directory)
          Save the directory used to import quote files.
static void putDisplaySettings(PreferencesManager.DisplayPreferences displayPreferences)
          Save display settings.
static void putHasGPLAcceptance()
          Set that the user has been shown the GPL and has accepted it.
static void putIDQuoteSyncPreferences(PreferencesManager.IDQuoteSyncPreferences idQuoteSyncPreferences)
          Save intra-day quote sync module preferences.
static void putLanguageCode(java.lang.String languageCode)
          Save language setting.
static void putLastPreferencesPage(int page)
          Save last preferences page visited.
static void putMaxDecimalDigits(java.lang.String maxDecimalDigits)
          Save user interface setting.
static void putMaximumCachedQuotes(int maximumCachedQuotes)
          Save the cache's maximum number of quotes.
static void putMinDecimalDigits(java.lang.String minDecimalDigits)
          Save user interface setting.
static void putPortfolio(Portfolio portfolio)
          Save the portfolio.
static void putProxySettings(PreferencesManager.ProxyPreferences proxyPreferences)
          Save proxy settings.
static void putQuoteSource(int quoteSource)
          Set quote source setting.
static void putStoredExpressions(java.util.List storedExpressions)
          Save the list of all stored expressions.
static void putStoredMacros(java.util.List stored_macros)
          Save the list of all registered macros.
static void putUserNotes(java.lang.String symbol, java.lang.String text)
           
static void putWatchScreen(WatchScreen watchScreen)
          Save the watch screen.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SAMPLES

public static int SAMPLES
Indicates the quote source is using the inbuilt sample quotes.


FILES

public static int FILES
Deprecated. Indicates the quote source is accessing quotes in files.

DATABASE

public static int DATABASE
Indicates the quote source is accessing quotes in a database


INTERNAL

public static int INTERNAL
Indicates the quote source is accessing the internal database

Method Detail

flush

public static void flush()
Forces the preferences data to be saved to the backend store (e.g. disk).


getUserNode

public static java.util.prefs.Preferences getUserNode(java.lang.String node)
Fetches the desired user node, based at the base branch

Parameters:
node - the path to the node to be fetched

getHasGPLAcceptance

public static boolean getHasGPLAcceptance()
Return whether we require the user to explicitly accept the GPL license. Currently the license must be explicilty accepted by the user for each version.

Returns:
true if the user needs to explicitly accept the GPL

putHasGPLAcceptance

public static void putHasGPLAcceptance()
Set that the user has been shown the GPL and has accepted it. The user will not be bothered again until the next version.


getDirectoryLocation

public static java.lang.String getDirectoryLocation(java.lang.String dirtype)
Load the last directory used when importing quote files.

Parameters:
dirtype - the directory type (e.g. macros, importer, etc)
Returns:
the directory.

putDirectoryLocation

public static void putDirectoryLocation(java.lang.String dirtype,
                                        java.lang.String directory)
Save the directory used to import quote files.

Parameters:
dirtype - the directory type (e.g. macros, importer, etc)
directory - the directory.

getStoredExpressions

public static java.util.List getStoredExpressions()
Load the list of all stored expressions.

Returns:
the list of stored expressions.
See Also:
StoredExpression

putStoredExpressions

public static void putStoredExpressions(java.util.List storedExpressions)
Save the list of all stored expressions.

Parameters:
storedExpressions - the stored expressions.
See Also:
StoredExpression

getStoredMacros

public static java.util.List getStoredMacros()
Load the list of all registered macros.

Returns:
the list of registered macros
See Also:
StoredMacro

putStoredMacros

public static void putStoredMacros(java.util.List stored_macros)
Save the list of all registered macros.

Parameters:
stored_macros - the registered macros.
See Also:
StoredMacro

putUserNotes

public static void putUserNotes(java.lang.String symbol,
                                java.lang.String text)

getUserNotes

public static java.lang.String getUserNotes(java.lang.String symbol)

getAnalyserPageSettings

public static java.util.HashMap getAnalyserPageSettings(java.lang.String key)
Load all saved user input in an Analyser Page.

Parameters:
key - a key which identifies which page settings to load.
Returns:
mapping of settings.
See Also:
AnalyserPage

putAnalyserPageSettings

public static void putAnalyserPageSettings(java.lang.String key,
                                           java.util.HashMap settings)
Save all user input in an Analyser Page.

Parameters:
key - a key which identifies which page settings to save.
settings - the settings to save.
See Also:
AnalyserPage

getLastPreferencesPage

public static int getLastPreferencesPage()
Load the last preferences page visited.

Returns:
index of the last preferences page visited.

putLastPreferencesPage

public static void putLastPreferencesPage(int page)
Save last preferences page visited.

Parameters:
page - index of the last preferences page visited.

getMaximumCachedQuotes

public static int getMaximumCachedQuotes()
Load the cache's maximum number of quotes.

Returns:
the maximum number of quotes.

putMaximumCachedQuotes

public static void putMaximumCachedQuotes(int maximumCachedQuotes)
Save the cache's maximum number of quotes.

Parameters:
maximumCachedQuotes - the maximum number of quotes.

getWatchScreenNames

public static java.util.List getWatchScreenNames()
Return a list of the names of all the watch screens.

Returns:
the list of watch screen names.

getWatchScreen

public static WatchScreen getWatchScreen(java.lang.String name)
Load the watch screen with the given name.

Parameters:
name - the name of the watch screen to load.
Returns:
the watch screen.

putWatchScreen

public static void putWatchScreen(WatchScreen watchScreen)
Save the watch screen.

Parameters:
watchScreen - the watch screen.

deleteWatchScreen

public static void deleteWatchScreen(java.lang.String name)
Delete the watch screen.

Parameters:
name - the watch screen name.

getPortfolioNames

public static java.util.List getPortfolioNames()
Return a list of the names of all the portfolios.

Returns:
the list of portfolio names.

deletePortfolio

public static void deletePortfolio(java.lang.String name)
Delete the portfolio.

Parameters:
name - the portfolio name.

getPortfolio

public static Portfolio getPortfolio(java.lang.String portfolioName)
                              throws PreferencesException
Load the portfolio with the given name.

Parameters:
portoflioName - the name of the portfolio to load.
Returns:
the portfolio.
Throws:
PreferencesException - if there was an error loading the portfolio.

putPortfolio

public static void putPortfolio(Portfolio portfolio)
                         throws PreferencesException
Save the portfolio.

Parameters:
portfolio - the portfolio.
Throws:
PreferencesException - if there was an error saving the portfolio.

getProxySettings

public static PreferencesManager.ProxyPreferences getProxySettings()
Load proxy settings.

Returns:
proxy preferences.

putProxySettings

public static void putProxySettings(PreferencesManager.ProxyPreferences proxyPreferences)
Save proxy settings.

Parameters:
proxyPreferences - the new proxy preferences.

getLanguageCode

public static java.lang.String getLanguageCode()
Load language setting. Returns null if there is no language setting saved in preferences.

Returns:
ISO Language Code

putLanguageCode

public static void putLanguageCode(java.lang.String languageCode)
Save language setting.

Parameters:
languageCode - ISO Language Code

getMinDecimalDigits

public static int getMinDecimalDigits()
Load user interface setting.

Returns:
the minimum decimal digits to be displayed

putMinDecimalDigits

public static void putMinDecimalDigits(java.lang.String minDecimalDigits)
Save user interface setting.

Parameters:
minDecimalDigits - the minimum decimal digits to be displayed

getMaxDecimalDigits

public static int getMaxDecimalDigits()
Load user interface setting.

Returns:
the maximum decimal digits to be displayed

putMaxDecimalDigits

public static void putMaxDecimalDigits(java.lang.String maxDecimalDigits)
Save user interface setting.

Parameters:
maxDecimalDigits - the maximum decimal digits to be displayed

getDefaultChart

public static java.lang.String getDefaultChart()
Load default chart setting.

Returns:
the default chart to be displayed

putDefaultChart

public static void putDefaultChart(java.lang.String defaultChart)
Save default chart setting.

Parameters:
defaultChart - the chart to be displayed

getQuoteSource

public static int getQuoteSource()
Get quote source setting.

Returns:
quote source, one of DATABASE, FILES or SAMPLES.

putQuoteSource

public static void putQuoteSource(int quoteSource)
Set quote source setting.

Parameters:
quoteSource - the quote source, one of DATABASE, INTERNAL or SAMPLES.

getDatabaseSettings

public static PreferencesManager.DatabasePreferences getDatabaseSettings()
Load database settings.

Returns:
database preferences.

putDatabaseSettings

public static void putDatabaseSettings(PreferencesManager.DatabasePreferences databasePreferences)
Save database settings.

Parameters:
databasePreferences - the new database preferences.

getInternalFileName

public static java.lang.String getInternalFileName()
Load the file name to store the internal database.

Returns:
internal database file name

getDisplaySettings

public static PreferencesManager.DisplayPreferences getDisplaySettings()
Load display settings.

Returns:
display preferences.

putDisplaySettings

public static void putDisplaySettings(PreferencesManager.DisplayPreferences displayPreferences)
Save display settings.

Parameters:
displayPreferences - the new display preferences.

getIDQuoteSyncPreferences

public static PreferencesManager.IDQuoteSyncPreferences getIDQuoteSyncPreferences()
Load intra-day quote sync module preferences.

Returns:
the preferences.
See Also:
IDQuoteSyncModule

putIDQuoteSyncPreferences

public static void putIDQuoteSyncPreferences(PreferencesManager.IDQuoteSyncPreferences idQuoteSyncPreferences)
Save intra-day quote sync module preferences.

Parameters:
idQuoteSyncPreferences - the preferences.
See Also:
IDQuoteSyncModule

Venice 0.7beta