ca.bc.gov.webade.preferences
Class DefaultWebADEPreferenceSet

java.lang.Object
  extended byca.bc.gov.webade.preferences.DefaultWebADEPreferenceSet
All Implemented Interfaces:
java.io.Serializable, WebADEPreferenceSet

public final class DefaultWebADEPreferenceSet
extends java.lang.Object
implements WebADEPreferenceSet, java.io.Serializable

Author:
jross
See Also:
Serialized Form

Constructor Summary
DefaultWebADEPreferenceSet(java.lang.String preferenceSetName)
          Creates a new preference set with the given set name.
 
Method Summary
 void addPreference(WebADEPreference pref)
          Adds the given preference to the current set, removing the previous one, if found.
 void clearPreferences()
          Removes all preferences from the current set.
 java.lang.Object clone()
          see java.lang.Object#clone()
 boolean equals(java.lang.Object obj)
           
 WebADEPreference getPreference(java.lang.String preferenceName)
          Returns the corresponding value for the given preference name, or null if not found.
 java.util.List getPreferenceNames()
          Returns the preference names of the preference set.
 java.util.Properties getPreferenceProperties(boolean convertMultiValuesToDelimitedString)
          Returns all preferences in the set as name value pairs in a Properties object.
 java.util.Properties getPreferenceProperties(boolean convertMultiValuesToDelimitedString, java.lang.String delimiterString)
          Returns all preferences in the set as name value pairs in a Properties object.
 java.util.List getPreferences()
          Returns the set of preferences.
 java.lang.String getPreferenceSetName()
           
 java.util.Properties getPreferencesProperties()
          Returns all preferences in the set as name value pairs in a Properties object.
 int hashCode()
           
 void removePreference(java.lang.String preferenceName)
          Removes the given preference from the current set.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultWebADEPreferenceSet

public DefaultWebADEPreferenceSet(java.lang.String preferenceSetName)
                           throws java.lang.NullPointerException
Creates a new preference set with the given set name.

Parameters:
preferenceSetName - The name of the preference set.
Throws:
java.lang.NullPointerException - Thrown if the preference set name parameter was null.
Method Detail

getPreferenceSetName

public final java.lang.String getPreferenceSetName()
Specified by:
getPreferenceSetName in interface WebADEPreferenceSet
Returns:
Returns the name.
See Also:
WebADEPreferenceSet.getPreferenceSetName()

getPreferences

public final java.util.List getPreferences()
Description copied from interface: WebADEPreferenceSet
Returns the set of preferences.

Specified by:
getPreferences in interface WebADEPreferenceSet
Returns:
An ArrayList of WebADEPreference objects.
See Also:
WebADEPreferenceSet.getPreferences()

getPreferenceNames

public final java.util.List getPreferenceNames()
Description copied from interface: WebADEPreferenceSet
Returns the preference names of the preference set.

Specified by:
getPreferenceNames in interface WebADEPreferenceSet
Returns:
An ArrayList of String objects.
See Also:
WebADEPreferenceSet.getPreferenceNames()

getPreference

public final WebADEPreference getPreference(java.lang.String preferenceName)
Description copied from interface: WebADEPreferenceSet
Returns the corresponding value for the given preference name, or null if not found.

Specified by:
getPreference in interface WebADEPreferenceSet
Parameters:
preferenceName - The unique name of the target preference in the set.
Returns:
A String value.
See Also:
WebADEPreferenceSet.getPreference(java.lang.String)

getPreferencesProperties

public final java.util.Properties getPreferencesProperties()
                                                    throws WebADEException
Description copied from interface: WebADEPreferenceSet
Returns all preferences in the set as name value pairs in a Properties object. Assumes that all preference objects in the set have at most one value assigned.

Specified by:
getPreferencesProperties in interface WebADEPreferenceSet
Returns:
A Properties object of String name-value pairs.
Throws:
WebADEException - Thrown if any of the WebADEPreference object within the set have more than one value assigned.
See Also:
WebADEPreferenceSet.getPreferencesProperties()

getPreferenceProperties

public java.util.Properties getPreferenceProperties(boolean convertMultiValuesToDelimitedString)
                                             throws WebADEException
Description copied from interface: WebADEPreferenceSet
Returns all preferences in the set as name value pairs in a Properties object. Assumes that all preference objects in the set have at most one value assigned.

Specified by:
getPreferenceProperties in interface WebADEPreferenceSet
Parameters:
convertMultiValuesToDelimitedString - Flag to convert multi-value preferences to a single comma-delimited value in the properties file (if set to true), or whether to throw an exception (if set to false).
Returns:
A Properties object of String name-value pairs.
Throws:
WebADEException - Thrown if any of the WebADEPreference object within the set have more than one value assigned, unless the convertMultiValuesToDelimitedString is set to true.
See Also:
WebADEPreferenceSet.getPreferenceProperties(boolean)

getPreferenceProperties

public java.util.Properties getPreferenceProperties(boolean convertMultiValuesToDelimitedString,
                                                    java.lang.String delimiterString)
                                             throws WebADEException
Description copied from interface: WebADEPreferenceSet
Returns all preferences in the set as name value pairs in a Properties object. Assumes that all preference objects in the set have at most one value assigned.

Specified by:
getPreferenceProperties in interface WebADEPreferenceSet
Parameters:
convertMultiValuesToDelimitedString - Flag to convert multi-value preferences to a single delimited value in the properties file (if set to true), or whether to throw an exception (if set to false).
delimiterString - The string used to delimit the multi-values string. The default value is a comma.
Returns:
A Properties object of String name-value pairs.
Throws:
WebADEException - Thrown if any of the WebADEPreference object within the set have more than one value assigned, unless the convertMultiValuesToDelimitedString is set to true.
See Also:
WebADEPreferenceSet.getPreferenceProperties(boolean, java.lang.String)

addPreference

public final void addPreference(WebADEPreference pref)
Description copied from interface: WebADEPreferenceSet
Adds the given preference to the current set, removing the previous one, if found.

Specified by:
addPreference in interface WebADEPreferenceSet
Parameters:
pref - The target preference.
See Also:
WebADEPreferenceSet.addPreference(ca.bc.gov.webade.preferences.WebADEPreference)

removePreference

public final void removePreference(java.lang.String preferenceName)
Description copied from interface: WebADEPreferenceSet
Removes the given preference from the current set.

Specified by:
removePreference in interface WebADEPreferenceSet
Parameters:
preferenceName - The name of the target preference.
See Also:
WebADEPreferenceSet.removePreference(java.lang.String)

clearPreferences

public final void clearPreferences()
Description copied from interface: WebADEPreferenceSet
Removes all preferences from the current set.

Specified by:
clearPreferences in interface WebADEPreferenceSet
See Also:
WebADEPreferenceSet.clearPreferences()

equals

public boolean equals(java.lang.Object obj)
See Also:
Object.equals(java.lang.Object)

toString

public java.lang.String toString()
See Also:
Object.toString()

hashCode

public int hashCode()
See Also:
Object.hashCode()

clone

public java.lang.Object clone()
see java.lang.Object#clone()

Specified by:
clone in interface WebADEPreferenceSet