Exemplo n.º 1
0
  /**
   * Gets a message from the resource bundle.
   *
   * @return null if no found
   */
  private static final String getFromBundle(int code, Locale locale) {
    final BundleInfo bi = Aide.getBundleInfo(code);
    final PropertyBundle rb = // case insensitive
        PropertyBundle.getBundle(bi.filename, locale, true);
    if (rb != null) return rb.getProperty(Integer.toHexString(code - getType(code)));

    throw new IllegalStateException("Missing resource: " + bi + " locale=" + locale);
  }
Exemplo n.º 2
0
  private static final String getNotFound(int code, Locale locale) {
    if (code == NULL_CODE) return ""; // special code

    try {
      log.error(
          "Message code not found: "
              + Integer.toHexString(code)
              + " not in "
              + locale
              + ":"
              + Aide.getBundleInfo(code));

      final String hexcode = Integer.toHexString(code);
      final String s = getFromBundle(MCommon.MESSAGE_CODE_NOT_FOUND, locale);
      return s != null
          ? MessageFormats.format(s, new Object[] {hexcode}, locale)
          : "Unknown message code: " + hexcode;
    } catch (Exception ex) {
      log.realCauseBriefly(ex);
      return "Unknown message code: " + Integer.toHexString(code);
    }
  }