edu.wisc.trace.urcsdk.support
Class UserPreferences

java.lang.Object
  extended by edu.wisc.trace.urcsdk.support.UserPreferences

public class UserPreferences
extends java.lang.Object

UserPreferences provides convenience methods for accessing a preferences mapping. Preferences are stored in an ordered list within the hashmap and the first item in the list carries the most value. If a user wants to grab the entire list of preferences, they can do so by calling the required convenience methods.

Known bugs: None
Thread Safe: Yes

Version:
$Revision: 1.21 $
Author:
Andrew Martin

Constructor Summary
UserPreferences()
          Creates a new UserPreferences instance.
 
Method Summary
 void addLanguage(java.lang.String language)
          addLanguage is a convenience wrapper for addProperty("languageContexts", language).
 void addProperty(java.lang.String name, java.lang.String value)
          Adds the given name/value pairing to the preferences mapping.
 java.lang.String getFormat()
           
 java.lang.String getLanguage()
          Describe getCurrentLanguage method here.
 java.util.List<java.lang.Object> getLanguages()
          Gets all the available languages that have been added to the preference map.
 java.lang.Object getPreference(java.lang.String prefName)
          Describe getPreference method here.
 java.util.Map<java.lang.String,java.util.List<java.lang.Object>> getPreferenceMap()
           
 java.util.List<java.lang.Object> getProperties(java.lang.String name)
          getProperties is a generic method for retrieving preferences generally.
 java.lang.Object getProperty(java.lang.String name)
          getProperty is a generic method for retrieving preferences generally.
 Constants.ResourceRole getRole()
          getRole is a convenience wrapper for getProperty("role")
 Constants.ResourceType getType()
           
 void setLanguage(java.lang.String lang)
          Describe setCurrentLangugage method here.
 void setProperty(java.lang.String name, java.lang.Object value)
          setProperty allows users to generically set properties without using the convenience methods.
 void setRole(java.lang.String role)
          setRole is a convenience wrapper for setProperty("role", role)
 void setType(Constants.ResourceType type)
           
 java.lang.String toString()
          Describe toString method here.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UserPreferences

public UserPreferences()
Creates a new UserPreferences instance. Sets default values for language ("en"), role ("label"), and type ("Text").

Method Detail

addProperty

public void addProperty(java.lang.String name,
                        java.lang.String value)
Adds the given name/value pairing to the preferences mapping.

Parameters:
name - a String object; the name of the preference.
value - a String object; the value of the preference.

addLanguage

public void addLanguage(java.lang.String language)
addLanguage is a convenience wrapper for addProperty("languageContexts", language).

Parameters:
language - a String value indicating the language to add.

getRole

public Constants.ResourceRole getRole()
getRole is a convenience wrapper for getProperty("role")

Returns:
a String value that is the currently preferred role.

getProperty

public java.lang.Object getProperty(java.lang.String name)
getProperty is a generic method for retrieving preferences generally.

Parameters:
name - a String object indicating which preference to retrieve.
Returns:
a String object that is the value of the preference named.

getProperties

public java.util.List<java.lang.Object> getProperties(java.lang.String name)
getProperties is a generic method for retrieving preferences generally.

Parameters:
name - a String object indicating which preference to retrieve.
Returns:
a List object that is the value of the preference named.

setRole

public void setRole(java.lang.String role)
setRole is a convenience wrapper for setProperty("role", role)

Parameters:
role - a String value indicating the preferred role.

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
setProperty allows users to generically set properties without using the convenience methods.

Parameters:
name - a String object; indicates the name of the preference to set.
value - a String object; the value of the preference to that is being set.

setLanguage

public void setLanguage(java.lang.String lang)
Describe setCurrentLangugage method here.

Parameters:
lang - a String value

getPreference

public java.lang.Object getPreference(java.lang.String prefName)
Describe getPreference method here.

Parameters:
prefName - a String value
Returns:
an Object value

toString

public java.lang.String toString()
Describe toString method here.

Overrides:
toString in class java.lang.Object
Returns:
a String value

getLanguage

public java.lang.String getLanguage()
Describe getCurrentLanguage method here.

Returns:
a String value

getLanguages

public java.util.List<java.lang.Object> getLanguages()
Gets all the available languages that have been added to the preference map.

Returns:
a String value

getType

public Constants.ResourceType getType()
Returns:
an enumeration of type ResourceType

setType

public void setType(Constants.ResourceType type)

getFormat

public java.lang.String getFormat()
Returns:
a String value

getPreferenceMap

public java.util.Map<java.lang.String,java.util.List<java.lang.Object>> getPreferenceMap()


Copyright © 2006 Trace R&D Center, University of Wisconsin-Madison. All Rights Reserved.