gluu
公開メンバ関数 | 非公開メンバ関数 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.xdi.oxauth.i18n.LanguageBean クラス
org.xdi.oxauth.i18n.LanguageBean の継承関係図
Inheritance graph
org.xdi.oxauth.i18n.LanguageBean 連携図
Collaboration graph

公開メンバ関数

String getLocaleCode ()
 
void setLocaleCode (String localeCode)
 
String getMessage (String key)
 

非公開メンバ関数

void setCookieValue (String value)
 
String getCookieValue ()
 
Cookie getCookie ()
 

非公開変数類

String localeCode = Locale.ENGLISH.getLanguage()
 

静的非公開変数類

static final long serialVersionUID = -6723715664277907737L
 
static final String COOKIE_NAME = "org.gluu.i18n.Locale"
 
static final int DEFAULT_MAX_AGE = 31536000
 
static final String COOKIE_PATH = "/"
 

詳解

バージョン
August 9, 2017

関数詳解

◆ getCookie()

Cookie org.xdi.oxauth.i18n.LanguageBean.getCookie ( )
inlineprivate
88  {
89  FacesContext ctx = FacesContext.getCurrentInstance();
90  if (ctx != null) {
91  return (Cookie) ctx.getExternalContext().getRequestCookieMap().get(COOKIE_NAME);
92  } else {
93  return null;
94  }
95  }
static final String COOKIE_NAME
Definition: LanguageBean.java:32

◆ getCookieValue()

String org.xdi.oxauth.i18n.LanguageBean.getCookieValue ( )
inlineprivate
83  {
84  Cookie cookie = getCookie();
85  return cookie == null ? null : cookie.getValue();
86  }
Cookie getCookie()
Definition: LanguageBean.java:88

◆ getLocaleCode()

String org.xdi.oxauth.i18n.LanguageBean.getLocaleCode ( )
inline
38  {
39  String localeCode = getCookieValue();
40  if (localeCode != null)
41  setLocaleCode(localeCode);
42 
43  return this.localeCode;
44  }
void setLocaleCode(String localeCode)
Definition: LanguageBean.java:46
String getCookieValue()
Definition: LanguageBean.java:83
String localeCode
Definition: LanguageBean.java:36

◆ getMessage()

String org.xdi.oxauth.i18n.LanguageBean.getMessage ( String  key)
inline
59  {
60  FacesContext context = FacesContext.getCurrentInstance();
61  ResourceBundle bundle = context.getApplication().getResourceBundle(context, "msgs");
62  String result;
63  try {
64  result = bundle.getString(key);
65  } catch (MissingResourceException e) {
66  result = "???" + key + "??? not found";
67  }
68  return result;
69  }

◆ setCookieValue()

void org.xdi.oxauth.i18n.LanguageBean.setCookieValue ( String  value)
inlineprivate
71  {
72  FacesContext ctx = FacesContext.getCurrentInstance();
73 
74  if (ctx == null)
75  return;
76  HttpServletResponse response = (HttpServletResponse) ctx.getExternalContext().getResponse();
77  Cookie cookie = new Cookie(COOKIE_NAME, value);
78  cookie.setMaxAge(DEFAULT_MAX_AGE);
79  cookie.setPath(COOKIE_PATH);
80  response.addCookie(cookie);
81  }
static final int DEFAULT_MAX_AGE
Definition: LanguageBean.java:33
static final String COOKIE_PATH
Definition: LanguageBean.java:34
static final String COOKIE_NAME
Definition: LanguageBean.java:32

◆ setLocaleCode()

void org.xdi.oxauth.i18n.LanguageBean.setLocaleCode ( String  localeCode)
inline
46  {
47  Iterator<Locale> locales = FacesContext.getCurrentInstance().getApplication().getSupportedLocales();
48  while (locales.hasNext()) {
49  Locale locale = locales.next();
50  if (!Strings.isEmpty(locale.getLanguage()) && locale.getLanguage().equals(localeCode)) {
51  this.localeCode = localeCode;
52  FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale(localeCode));
54  break;
55  }
56  }
57  }
String localeCode
Definition: LanguageBean.java:36
void setCookieValue(String value)
Definition: LanguageBean.java:71

メンバ詳解

◆ COOKIE_NAME

final String org.xdi.oxauth.i18n.LanguageBean.COOKIE_NAME = "org.gluu.i18n.Locale"
staticprivate

◆ COOKIE_PATH

final String org.xdi.oxauth.i18n.LanguageBean.COOKIE_PATH = "/"
staticprivate

◆ DEFAULT_MAX_AGE

final int org.xdi.oxauth.i18n.LanguageBean.DEFAULT_MAX_AGE = 31536000
staticprivate

◆ localeCode

String org.xdi.oxauth.i18n.LanguageBean.localeCode = Locale.ENGLISH.getLanguage()
private

◆ serialVersionUID

final long org.xdi.oxauth.i18n.LanguageBean.serialVersionUID = -6723715664277907737L
staticprivate

このクラス詳解は次のファイルから抽出されました: