ca.bc.gov.webade
Class Preferences

java.lang.Object
  extended byca.bc.gov.webade.Preferences
All Implemented Interfaces:
java.io.Serializable

public final class Preferences
extends java.lang.Object
implements java.io.Serializable

Contains the set of Preference objects and the set of PreferenceSet objects for a particular target(Global, Application, Extension, User).

Author:
jross
See Also:
Serialized Form

Constructor Summary
Preferences()
          Default Constructor.
Preferences(Preferences prefs)
          Clone Constructor.
 
Method Summary
 void addPreference(Preference pref)
          Adds the given Preference object to the set of preferences.
 void addPreferenceSet(PreferenceSet prefSet)
          Adds the given Preference object to the target set of preferences identified by the set name.
 void addPreferenceToSet(java.lang.String setName, Preference pref)
          Adds the given Preference object to the target set of preferences identified by the set name.
static Preferences convertToPreferences(WebADEPreferences prefs)
           
static WebADEPreferences convertToWebADEPreferences(Preferences prefs)
           
 Preference getPreference(java.lang.String preferenceSubType, java.lang.String preferenceName)
          Returns the target preference, identified by sub-type and name.
 java.util.Properties getPreferencePropertiesBySubType(java.lang.String preferenceSubType)
          Returns the preferences that match the given subtype as name value pairs in a Properties object.
 java.util.Iterator getPreferences()
          Returns the set of preferences.
 java.util.ArrayList getPreferencesBySubType(java.lang.String preferenceSubType)
          Returns the preferences that match the given subtype.
 PreferenceSet getPreferenceSet(java.lang.String preferenceSubType, java.lang.String preferenceSetName)
          Returns the target preference set.
 java.util.Iterator getPreferenceSets()
          Returns the preference sets.
 java.util.ArrayList getPreferenceSetsBySubType(java.lang.String preferenceSubType)
          Returns the preference sets that match the given subtype.
 java.util.ArrayList getPreferenceSubTypes()
          Returns all subtypes in the .
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Preferences

public Preferences()
Default Constructor.


Preferences

public Preferences(Preferences prefs)
Clone Constructor.

Parameters:
prefs - The Preferences object to clone.
Method Detail

convertToPreferences

public static final Preferences convertToPreferences(WebADEPreferences prefs)
Parameters:
prefs - The WebADEPreferences object to convert.
Returns:
The Preferences object.

convertToWebADEPreferences

public static final WebADEPreferences convertToWebADEPreferences(Preferences prefs)
Parameters:
prefs - The Preferences object to convert.
Returns:
The WebADEPreferences object.

getPreferenceSubTypes

public java.util.ArrayList getPreferenceSubTypes()
Returns all subtypes in the .

Returns:
An ArrayList of Preference objects matching the sub-type.

getPreference

public Preference getPreference(java.lang.String preferenceSubType,
                                java.lang.String preferenceName)
Returns the target preference, identified by sub-type and name.

Parameters:
preferenceSubType - The sub-type containing the preference.
preferenceName - The target preference name.
Returns:
The target Preference object, or null if not found.

getPreferencesBySubType

public java.util.ArrayList getPreferencesBySubType(java.lang.String preferenceSubType)
Returns the preferences that match the given subtype.

Parameters:
preferenceSubType - The sub-type containing the preference.
Returns:
An ArrayList of Preference objects matching the sub-type.

getPreferencePropertiesBySubType

public java.util.Properties getPreferencePropertiesBySubType(java.lang.String preferenceSubType)
                                                      throws WebADEException
Returns the preferences that match the given subtype as name value pairs in a Properties object. Assumes that all preference objects with the given subtype have at most one value assigned.

Parameters:
preferenceSubType - The sub-type containing the preference.
Returns:
A Properties object of String name-value pairs.
Throws:
WebADEException - Thrown if any of the Preference object with the given subtype have more than one value assigned.

getPreferences

public java.util.Iterator getPreferences()
Returns the set of preferences.

Returns:
An Iterator of Preference objects.

getPreferenceSet

public PreferenceSet getPreferenceSet(java.lang.String preferenceSubType,
                                      java.lang.String preferenceSetName)
                               throws WebADEException
Returns the target preference set. Assumes that there will be only one match for the given sub-type/set-name combination. If more than one match is found, and exception is thrown.

Parameters:
preferenceSubType - The sub-type containing the preference.
preferenceSetName - The target preference set name.
Returns:
The target PreferenceSet object, or null if not found.
Throws:
WebADEException - Thrown if more than one preference set match is found.

getPreferenceSetsBySubType

public java.util.ArrayList getPreferenceSetsBySubType(java.lang.String preferenceSubType)
Returns the preference sets that match the given subtype.

Parameters:
preferenceSubType - The sub-type containing the preference.
Returns:
An ArrayList of PreferenceSet objects matching the sub-type.

getPreferenceSets

public java.util.Iterator getPreferenceSets()
Returns the preference sets.

Returns:
An Iterator of PreferenceSet objects.

addPreference

public final void addPreference(Preference pref)
                         throws WebADEException
Adds the given Preference object to the set of preferences.

Parameters:
pref - The target preference to add.
Throws:
WebADEException - thrown if the preference-type does not match the Preferences preference-type

addPreferenceToSet

public final void addPreferenceToSet(java.lang.String setName,
                                     Preference pref)
                              throws WebADEException
Adds the given Preference object to the target set of preferences identified by the set name.

Parameters:
setName - The preference set to add the preference to.
pref - The target preference to add.
Throws:
WebADEException - thrown if the preference-type does not match the Preferences preference-type

addPreferenceSet

public final void addPreferenceSet(PreferenceSet prefSet)
                            throws WebADEException
Adds the given Preference object to the target set of preferences identified by the set name.

Parameters:
prefSet - The target preference set to add.
Throws:
WebADEException - thrown if the preference-type does not match the Preferences preference-type