org.browsecode.helpers.preferences
Class PreferencesFromFile

java.lang.Object
  extended by org.browsecode.helpers.preferences.PreferencesFromFile
All Implemented Interfaces:
HasKeyValues, HasKeyValuesModifiable, KeyValuesModifiable, Preferences

public class PreferencesFromFile
extends java.lang.Object
implements Preferences

Preferences loads and saves prefs to a file for a particular program (or set of programs). It also automatically saves the preferences when the system exits. You may call "savePrefs()" if you want to, but you don't have to.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.browsecode.helpers.keyvalues.HasKeyValuesModifiable
HasKeyValuesModifiable.Hash
 
Method Summary
 java.lang.Boolean getBooleanObjectPreference(java.lang.String key)
           
 boolean getBooleanPreference(java.lang.String key)
          Returns false if the value isn't in the database, by default.
 boolean getBooleanPreference(java.lang.String key, boolean defaultValue)
          Returns false if the value isn't in the database, by default.
 java.util.Vector<java.lang.Boolean> getBooleanPreferenceVector(java.lang.String key)
           
 java.lang.Integer getIntegerPreference(java.lang.String key)
           
 int getIntPreference(java.lang.String key)
          Returns -1 if the value isn't in the database.
 java.lang.String getPreference(java.lang.String key)
           
 java.lang.String[] getPreferenceList(java.lang.String key)
           
 Preferences getPreferencesSubset(java.lang.String key)
           
 Preferences getPreferencesSubsetFromVector(java.lang.String key, int vectorIndex)
           
 Preferences getPreferencesSubsetFromVectorName(java.lang.String vectorName)
           
 Preferences getPreferencesSubsetFromVectorName(java.lang.String key, java.lang.String vectorName)
           
 java.util.Vector<java.lang.String> getPreferenceVector(java.lang.String key)
           
 java.util.Vector<java.util.Vector<java.lang.String>> getPreferenceVectorOfVectors(java.lang.String key)
           
 java.lang.String getValue(java.lang.String key)
           
static void main(java.lang.String[] args)
           
 void removePreferenceVectorIndex(java.lang.String key, int indexToDelete)
           
 void savePrefs()
           
 void setBooleanObjectPreference(java.lang.String key, java.lang.Boolean value)
           
 void setBooleanPreference(java.lang.String key, boolean value)
           
 void setBooleanPreferenceVector(java.lang.String key, java.util.Vector<java.lang.Boolean> v)
           
 void setIntegerPreference(java.lang.String key, java.lang.Integer value)
           
 void setIntPreference(java.lang.String key, int value)
           
 void setPreference(java.lang.String key, java.lang.String value)
           
 void setPreferenceList(java.lang.String key, java.lang.String[] values)
           
 void setPreferenceVector(java.lang.String key, java.util.Vector<java.lang.String> v)
           
 void setPreferenceVectorOfVectors(java.lang.String key, java.util.Vector<java.util.Vector<java.lang.String>> v)
           
 void setValue(java.lang.String key, java.lang.String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

savePrefs

public void savePrefs()
Specified by:
savePrefs in interface Preferences

getPreferenceList

public java.lang.String[] getPreferenceList(java.lang.String key)
Specified by:
getPreferenceList in interface Preferences

removePreferenceVectorIndex

public void removePreferenceVectorIndex(java.lang.String key,
                                        int indexToDelete)
Specified by:
removePreferenceVectorIndex in interface Preferences

setPreferenceVector

public void setPreferenceVector(java.lang.String key,
                                java.util.Vector<java.lang.String> v)
Specified by:
setPreferenceVector in interface Preferences

setBooleanPreferenceVector

public void setBooleanPreferenceVector(java.lang.String key,
                                       java.util.Vector<java.lang.Boolean> v)
Specified by:
setBooleanPreferenceVector in interface Preferences

setPreferenceVectorOfVectors

public void setPreferenceVectorOfVectors(java.lang.String key,
                                         java.util.Vector<java.util.Vector<java.lang.String>> v)
Specified by:
setPreferenceVectorOfVectors in interface Preferences

getPreferenceVector

public java.util.Vector<java.lang.String> getPreferenceVector(java.lang.String key)
Specified by:
getPreferenceVector in interface Preferences

getBooleanPreferenceVector

public java.util.Vector<java.lang.Boolean> getBooleanPreferenceVector(java.lang.String key)
Specified by:
getBooleanPreferenceVector in interface Preferences

getPreferenceVectorOfVectors

public java.util.Vector<java.util.Vector<java.lang.String>> getPreferenceVectorOfVectors(java.lang.String key)
Specified by:
getPreferenceVectorOfVectors in interface Preferences

getIntPreference

public int getIntPreference(java.lang.String key)
Returns -1 if the value isn't in the database.

Specified by:
getIntPreference in interface Preferences
Parameters:
key -
Returns:

getIntegerPreference

public java.lang.Integer getIntegerPreference(java.lang.String key)
Specified by:
getIntegerPreference in interface Preferences

getBooleanPreference

public boolean getBooleanPreference(java.lang.String key)
Returns false if the value isn't in the database, by default.

Specified by:
getBooleanPreference in interface Preferences
Parameters:
key -
Returns:

getBooleanPreference

public boolean getBooleanPreference(java.lang.String key,
                                    boolean defaultValue)
Returns false if the value isn't in the database, by default.

Specified by:
getBooleanPreference in interface Preferences
Parameters:
key -
Returns:

getBooleanObjectPreference

public java.lang.Boolean getBooleanObjectPreference(java.lang.String key)
Specified by:
getBooleanObjectPreference in interface Preferences

getPreference

public java.lang.String getPreference(java.lang.String key)
Specified by:
getPreference in interface Preferences

setPreference

public void setPreference(java.lang.String key,
                          java.lang.String value)
Specified by:
setPreference in interface Preferences

setIntPreference

public void setIntPreference(java.lang.String key,
                             int value)
Specified by:
setIntPreference in interface Preferences

setIntegerPreference

public void setIntegerPreference(java.lang.String key,
                                 java.lang.Integer value)
Specified by:
setIntegerPreference in interface Preferences

setBooleanPreference

public void setBooleanPreference(java.lang.String key,
                                 boolean value)
Specified by:
setBooleanPreference in interface Preferences

setBooleanObjectPreference

public void setBooleanObjectPreference(java.lang.String key,
                                       java.lang.Boolean value)
Specified by:
setBooleanObjectPreference in interface Preferences

setPreferenceList

public void setPreferenceList(java.lang.String key,
                              java.lang.String[] values)
Specified by:
setPreferenceList in interface Preferences

getPreferencesSubset

public Preferences getPreferencesSubset(java.lang.String key)
Specified by:
getPreferencesSubset in interface Preferences

getPreferencesSubsetFromVector

public Preferences getPreferencesSubsetFromVector(java.lang.String key,
                                                  int vectorIndex)
Specified by:
getPreferencesSubsetFromVector in interface Preferences

getPreferencesSubsetFromVectorName

public Preferences getPreferencesSubsetFromVectorName(java.lang.String vectorName)
Specified by:
getPreferencesSubsetFromVectorName in interface Preferences

getPreferencesSubsetFromVectorName

public Preferences getPreferencesSubsetFromVectorName(java.lang.String key,
                                                      java.lang.String vectorName)
Specified by:
getPreferencesSubsetFromVectorName in interface Preferences

setValue

public void setValue(java.lang.String key,
                     java.lang.String value)
Specified by:
setValue in interface KeyValuesModifiable

getValue

public java.lang.String getValue(java.lang.String key)
Specified by:
getValue in interface HasKeyValues

main

public static final void main(java.lang.String[] args)