org.homeunix.thecave.buddi.plugin.api
Class PreferenceAccess

java.lang.Object
  extended by org.homeunix.thecave.buddi.plugin.api.PreferenceAccess
Direct Known Subclasses:
BuddiPreferencePlugin, BuddiReportPlugin, BuddiRunnablePlugin, MenuPlugin

public abstract class PreferenceAccess
extends java.lang.Object

An abstract class which provides plugins the functionality of storing and reading preferences in the main Buddi preferences file.

Author:
wyatt

Constructor Summary
PreferenceAccess()
           
 
Method Summary
 java.util.List<java.lang.String> getListPreference(java.lang.String key)
          Returns the list associated with the given key.
 java.lang.String getPreference(java.lang.String key)
          Loads the value which is associated with the given key.
 java.lang.String getSecurePreference(java.lang.String key, char[] password)
          Loads the value which is associated with the given key, after decrypting the value using the given password.
 void putListPreference(java.lang.String key, java.util.List<java.lang.String> values)
          Sets the given list of strings in the preferences map, using the given key.
 void putPreference(java.lang.String key, java.lang.String value)
          Stores the value associated with a given key.
 void putSecurePreference(java.lang.String key, java.lang.String value, char[] password)
          Stores the value, encrypted using the given password, into the preferences file using the given key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PreferenceAccess

public PreferenceAccess()
Method Detail

getPreference

public java.lang.String getPreference(java.lang.String key)
Loads the value which is associated with the given key.

Parameters:
key - The key to read.
Returns:
The value associated with the given key, or null if there was no such value set.

putPreference

public void putPreference(java.lang.String key,
                          java.lang.String value)
Stores the value associated with a given key.

Parameters:
key - The key to save. In order to ensure that you do not overwrite the preferences for another plugin, you must use the key format as follows: "package.Plugin.property" For instance, use the key "com.example.buddi.ImportFoo.LAST_EXECUTE_DAY" instead of the key "LAST_EXECUTE_DAY".
value - The value to store. Can be any valid String.

putListPreference

public void putListPreference(java.lang.String key,
                              java.util.List<java.lang.String> values)
Sets the given list of strings in the preferences map, using the given key.

Parameters:
key - The key to save. In order to ensure that you do not overwrite the preferences for another plugin, you must use the key format as follows: "package.Plugin.property" For instance, use the key "com.example.buddi.ImportFoo.LAST_EXECUTE_DAY" instead of the key "LAST_EXECUTE_DAY".
values - The list of values to store

getListPreference

public java.util.List<java.lang.String> getListPreference(java.lang.String key)
Returns the list associated with the given key.

Parameters:
key - The key to save. In order to ensure that you do not overwrite the preferences for another plugin, you must use the key format as follows: "package.Plugin.property" For instance, use the key "com.example.buddi.ImportFoo.LAST_EXECUTE_DAY" instead of the key "LAST_EXECUTE_DAY".
Returns:

getSecurePreference

public java.lang.String getSecurePreference(java.lang.String key,
                                            char[] password)
                                     throws PluginException
Loads the value which is associated with the given key, after decrypting the value using the given password.

Parameters:
key -
password -
Returns:
Throws:
PluginException

putSecurePreference

public void putSecurePreference(java.lang.String key,
                                java.lang.String value,
                                char[] password)
                         throws PluginException
Stores the value, encrypted using the given password, into the preferences file using the given key.

Parameters:
key -
value -
password -
Throws:
PluginException