public class Preferences extends HashMap<String,String>
Modifier and Type | Class and Description |
---|---|
static class |
Preferences.TimeFormat
Is used to choose between the different date formats that JSPWiki supports.
|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Field and Description |
---|---|
static String |
SESSIONPREFS
The name under which a Preferences object is stored in the HttpSession.
|
Constructor and Description |
---|
Preferences() |
Modifier and Type | Method and Description |
---|---|
static ResourceBundle |
getBundle(WikiContext context,
String bundle)
Locates the i18n ResourceBundle given.
|
static SimpleDateFormat |
getDateFormat(WikiContext context,
Preferences.TimeFormat tf)
Get SimpleTimeFormat according to user browser locale and preferred time
formats.
|
static Locale |
getLocale(WikiContext context)
Get Locale according to user-preference settings or the user browser locale
|
static String |
getPreference(javax.servlet.jsp.PageContext pageContext,
String name)
Returns a preference value programmatically.
|
static String |
getPreference(WikiContext wikiContext,
String name)
Returns a preference value programmatically.
|
static void |
reloadPreferences(javax.servlet.jsp.PageContext pageContext)
Reloads the preferences from the PageContext into the WikiContext.
|
static String |
renderDate(WikiContext context,
Date date,
Preferences.TimeFormat tf)
A simple helper function to render a date based on the user preferences.
|
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.
|
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
equals, hashCode, toString
public static final String SESSIONPREFS
public Preferences()
public static void setupPreferences(javax.servlet.jsp.PageContext pageContext)
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.
pageContext
- The JSP PageContext.public static void reloadPreferences(javax.servlet.jsp.PageContext pageContext)
pageContext
- The page context.public static String getPreference(WikiContext wikiContext, String name)
wikiContext
- name
- public static String getPreference(javax.servlet.jsp.PageContext pageContext, String name)
pageContext
- name
- public static Locale getLocale(WikiContext context)
context
- The context to examine.public static ResourceBundle getBundle(WikiContext context, String bundle) throws MissingResourceException
context
- WikiContext
holding the user's localebundle
- The name of the bundle you are looking for.MissingResourceException
- If the bundle cannot be foundInternationalizationManager
public static SimpleDateFormat getDateFormat(WikiContext context, Preferences.TimeFormat tf)
context
- WikiContext to use for rendering.tf
- Which version of the dateformat you are looking for?public static String renderDate(WikiContext context, Date date, Preferences.TimeFormat tf)
context
- The context which is used to get the preferencesdate
- The date to render.tf
- In which format the date should be rendered.Copyright © 2001-2019 The Apache Software Foundation. All rights reserved.