Ejemplo n.º 1
0
 @Override
 public String toDebugString(boolean prettyFormat, Locale locale) {
   if (prettyFormat && values != null && !values.isEmpty()) {
     final StringBuilder sb = new StringBuilder();
     for (final String localeKey : values.keySet()) {
       if (!values.get(localeKey).isEmpty()) {
         sb.append("Locale: ")
             .append(LocaleHelper.debugLabel(LocaleHelper.parseLocaleString(localeKey)))
             .append("\n");
         for (final String value : values.get(localeKey)) {
           sb.append("  ").append(value).append("\n");
         }
       }
     }
     return sb.toString();
   } else {
     return JsonUtil.serializeMap(values);
   }
 }
Ejemplo n.º 2
0
  public String asLongString(final Locale locale) {
    final TimeDetail timeDetail = getTimeDetail();
    final StringBuilder sb = new StringBuilder();

    // output number of days
    if (timeDetail.days > 0) {
      sb.append(timeDetail.days);
      sb.append(" ");
      sb.append(
          timeDetail.days == 1
              ? LocaleHelper.getLocalizedMessage(locale, Display.Display_Day, null)
              : LocaleHelper.getLocalizedMessage(locale, Display.Display_Days, null));
    }

    // output number of hours
    if (timeDetail.hours > 0) {
      if (sb.length() > 0) {
        sb.append(", ");
      }
      sb.append(timeDetail.hours);
      sb.append(" ");
      sb.append(
          timeDetail.hours == 1
              ? LocaleHelper.getLocalizedMessage(locale, Display.Display_Hour, null)
              : LocaleHelper.getLocalizedMessage(locale, Display.Display_Hours, null));
    }

    // output number of minutes
    if (timeDetail.minutes > 0) {
      if (sb.length() > 0) {
        sb.append(", ");
      }
      sb.append(timeDetail.minutes);
      sb.append(" ");
      sb.append(
          timeDetail.minutes == 1
              ? LocaleHelper.getLocalizedMessage(locale, Display.Display_Minute, null)
              : LocaleHelper.getLocalizedMessage(locale, Display.Display_Minutes, null));
    }

    // seconds
    if (timeDetail.seconds > 0 || sb.toString().isEmpty()) {
      if (sb.length() > 0) {
        sb.append(", ");
      }
      if (sb.length() == 0) {
        if (ms < 5000) {
          sb.append(new BigDecimal(ms).movePointLeft(3).stripTrailingZeros());

          if (ms > 1000) {
            sb.deleteCharAt(sb.length() - 1);
          }

          if (ms > 2000) {
            sb.deleteCharAt(sb.length() - 1);
          }

        } else {
          sb.append(timeDetail.seconds);
        }
      } else {
        sb.append(timeDetail.seconds);
      }
      sb.append(" ");
      sb.append(
          ms == 1000
              ? LocaleHelper.getLocalizedMessage(locale, Display.Display_Second, null)
              : LocaleHelper.getLocalizedMessage(locale, Display.Display_Seconds, null));
    }

    return sb.toString();
  }
Ejemplo n.º 3
0
 @Override
 public String getCurrentDisplayInstructions() {
   final String key = "Display_NAAF_" + naafLoginSequence.currentMethod();
   return LocaleHelper.getLocalizedMessage(locale, key, pwmApplication.getConfig(), Display.class);
 }