コード例 #1
0
ファイル: MessageText.java プロジェクト: aprasa/oldwork
  private static String getResourceBundleString(String key) {
    if (key == null) {
      return "";
    }

    String value = RESOURCE_BUNDLE.getString(key);

    // Replace {*} with a lookup of *
    if (value != null && value.indexOf('}') > 0) {
      Matcher matcher = PAT_PARAM_ALPHA.matcher(value);
      while (matcher.find()) {
        key = matcher.group(1);
        try {
          String text = getResourceBundleString(key);
          if (text != null) {
            value = value.replaceAll("\\Q{" + key + "}\\E", text);
          }
        } catch (MissingResourceException e) {
          // ignore error
        }
      }
    }

    return value;
  }
コード例 #2
0
ファイル: MessageText.java プロジェクト: aprasa/oldwork
 public static boolean keyExistsForDefaultLocale(final String key) {
   try {
     DEFAULT_BUNDLE.getString(key);
     return true;
   } catch (MissingResourceException e) {
     return false;
   }
 }
コード例 #3
0
ファイル: MessageText.java プロジェクト: aprasa/oldwork
 public static String getDefaultLocaleString(String key) {
   // TODO Auto-generated method stub
   try {
     return DEFAULT_BUNDLE.getString(key);
   } catch (MissingResourceException e) {
     // we support the usage of non-resource strings as long as they are wrapped in !
     if (key.startsWith("!") && key.endsWith("!")) {
       return (key.substring(1, key.length() - 1));
     }
     return '!' + key + '!';
   }
 }