Package org.apache.wiki.preferences
Class Preferences
- java.lang.Object
- 
- java.util.AbstractMap<K,V>
- 
- java.util.HashMap<java.lang.String,java.lang.String>
- 
- org.apache.wiki.preferences.Preferences
 
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Cloneable,- java.util.Map<java.lang.String,java.lang.String>
 
 public class Preferences extends java.util.HashMap<java.lang.String,java.lang.String> Represents an object which is used to store user preferences.- See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classPreferences.TimeFormatIs used to choose between the different date formats that JSPWiki supports.
 - 
Field SummaryFields Modifier and Type Field Description static java.lang.StringCOOKIE_USER_PREFS_NAMEstatic java.lang.StringSESSIONPREFSThe name under which a Preferences object is stored in the HttpSession.
 - 
Constructor SummaryConstructors Constructor Description Preferences()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.ResourceBundlegetBundle(Context context, java.lang.String bundle)Locates the i18n ResourceBundle given.static java.text.SimpleDateFormatgetDateFormat(Context context, Preferences.TimeFormat tf)Get SimpleTimeFormat according to user browser locale and preferred time formats.static java.util.LocalegetLocale(Context context)Get Locale according to user-preference settings or the user browser localestatic java.lang.StringgetPreference(javax.servlet.jsp.PageContext pageContext, java.lang.String name)Returns a preference value programmatically.static java.lang.StringgetPreference(Context wikiContext, java.lang.String name)Returns a preference value programmatically.static voidreloadPreferences(javax.servlet.jsp.PageContext pageContext)Reloads the preferences from the PageContext into the WikiContext.static java.lang.StringrenderDate(Context context, java.util.Date date, Preferences.TimeFormat tf)A simple helper function to render a date based on the user preferences.static voidsetupPreferences(javax.servlet.jsp.PageContext pageContext)This is an utility method which is called to make sure that the JSP pages do have proper access to any user preferences.- 
Methods inherited from class java.util.HashMapclear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
 
- 
 
- 
- 
- 
Field Detail- 
SESSIONPREFSpublic static final java.lang.String SESSIONPREFS The name under which a Preferences object is stored in the HttpSession. Its value is "prefs".- See Also:
- Constant Field Values
 
 - 
COOKIE_USER_PREFS_NAMEpublic static final java.lang.String COOKIE_USER_PREFS_NAME - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
Preferencespublic Preferences() 
 
- 
 - 
Method Detail- 
setupPreferencespublic static void setupPreferences(javax.servlet.jsp.PageContext pageContext) This is an utility method which is called to make sure that the JSP pages do have proper access to any user preferences. It should be called from the commonheader.jsp.This method reads user cookie preferences and mixes them up with any default preferences (and in the future, any user-specific preferences) and puts them all in the session, so that they do not have to be rewritten again. This method will remember if the user has already changed his prefs. - Parameters:
- pageContext- The JSP PageContext.
 
 - 
reloadPreferencespublic static void reloadPreferences(javax.servlet.jsp.PageContext pageContext) Reloads the preferences from the PageContext into the WikiContext.- Parameters:
- pageContext- The page context.
 
 - 
getPreferencepublic static java.lang.String getPreference(Context wikiContext, java.lang.String name) Returns a preference value programmatically. FIXME- Parameters:
- wikiContext-
- name-
- Returns:
- the preference value
 
 - 
getPreferencepublic static java.lang.String getPreference(javax.servlet.jsp.PageContext pageContext, java.lang.String name) Returns a preference value programmatically. FIXME- Parameters:
- pageContext-
- name-
- Returns:
- the preference value
 
 - 
getLocalepublic static java.util.Locale getLocale(Context context) Get Locale according to user-preference settings or the user browser locale- Parameters:
- context- The context to examine.
- Returns:
- a Locale object.
- Since:
- 2.8
 
 - 
getBundlepublic static java.util.ResourceBundle getBundle(Context context, java.lang.String bundle) throws java.util.MissingResourceException Locates the i18n ResourceBundle given. This method interprets the request locale, and uses that to figure out which language the user wants.- Parameters:
- context-- Contextholding the user's locale
- bundle- The name of the bundle you are looking for.
- Returns:
- A localized string (or from the default language, if not found)
- Throws:
- java.util.MissingResourceException- If the bundle cannot be found
- See Also:
- InternationalizationManager
 
 - 
getDateFormatpublic static java.text.SimpleDateFormat getDateFormat(Context context, Preferences.TimeFormat tf) Get SimpleTimeFormat according to user browser locale and preferred time formats. If not found, it will revert to whichever format is set for the default.- Parameters:
- context- WikiContext to use for rendering.
- tf- Which version of the dateformat you are looking for?
- Returns:
- A SimpleTimeFormat object which you can use to render
- Since:
- 2.8
 
 - 
renderDatepublic static java.lang.String renderDate(Context context, java.util.Date date, Preferences.TimeFormat tf) A simple helper function to render a date based on the user preferences. This is useful for example for all plugins.- Parameters:
- context- The context which is used to get the preferences
- date- The date to render.
- tf- In which format the date should be rendered.
- Returns:
- A ready-rendered date.
- Since:
- 2.8
 
 
- 
 
-