keycloak-service
公開メンバ関数 | 限定公開メンバ関数 | 限定公開変数類 | 全メンバ一覧
org.keycloak.theme.beans.LinkExpirationFormatterMethod クラス
org.keycloak.theme.beans.LinkExpirationFormatterMethod の継承関係図
Inheritance graph
org.keycloak.theme.beans.LinkExpirationFormatterMethod 連携図
Collaboration graph

公開メンバ関数

 LinkExpirationFormatterMethod (Properties messages, Locale locale)
 
Object exec (List arguments) throws TemplateModelException
 

限定公開メンバ関数

String format (long valueInSeconds)
 
String getUnitTextFromMessages (String unitKey, long value)
 

限定公開変数類

final Properties messages
 
final Locale locale
 

詳解

Method used to format link expiration time period in emails.

著者
Vlastimil Elias (velias at redhat dot com)

構築子と解体子

◆ LinkExpirationFormatterMethod()

org.keycloak.theme.beans.LinkExpirationFormatterMethod.LinkExpirationFormatterMethod ( Properties  messages,
Locale  locale 
)
inline
25  {
26  this.messages = messages;
27  this.locale = locale;
28  }
final Locale locale
Definition: LinkExpirationFormatterMethod.java:23
final Properties messages
Definition: LinkExpirationFormatterMethod.java:22

関数詳解

◆ exec()

Object org.keycloak.theme.beans.LinkExpirationFormatterMethod.exec ( List  arguments) throws TemplateModelException
inline
32  {
33  Object val = arguments.isEmpty() ? null : arguments.get(0);
34  if (val == null)
35  return "";
36 
37  try {
38  //input value is in minutes, as defined in EmailTemplateProvider!
39  return format(Long.parseLong(val.toString().trim()) * 60);
40  } catch (NumberFormatException e) {
41  // not a number, return it as is
42  return val.toString();
43  }
44 
45  }
String format(long valueInSeconds)
Definition: LinkExpirationFormatterMethod.java:47

◆ format()

String org.keycloak.theme.beans.LinkExpirationFormatterMethod.format ( long  valueInSeconds)
inlineprotected
47  {
48 
49  String unitKey = "seconds";
50  long value = valueInSeconds;
51 
52  if (value > 0 && value % 60 == 0) {
53  unitKey = "minutes";
54  value = value / 60;
55  if (value % 60 == 0) {
56  unitKey = "hours";
57  value = value / 60;
58  if (value % 24 == 0) {
59  unitKey = "days";
60  value = value / 24;
61  }
62  }
63  }
64 
65  return value + " " + getUnitTextFromMessages(unitKey, value);
66  }
String getUnitTextFromMessages(String unitKey, long value)
Definition: LinkExpirationFormatterMethod.java:68

◆ getUnitTextFromMessages()

String org.keycloak.theme.beans.LinkExpirationFormatterMethod.getUnitTextFromMessages ( String  unitKey,
long  value 
)
inlineprotected
68  {
69  String msg = messages.getProperty("linkExpirationFormatter.timePeriodUnit." + unitKey + "." + value);
70  if (msg != null)
71  return msg;
72  return messages.getProperty("linkExpirationFormatter.timePeriodUnit." + unitKey);
73  }
final Properties messages
Definition: LinkExpirationFormatterMethod.java:22

メンバ詳解

◆ locale

final Locale org.keycloak.theme.beans.LinkExpirationFormatterMethod.locale
protected

◆ messages

final Properties org.keycloak.theme.beans.LinkExpirationFormatterMethod.messages
protected

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