當前位置: 首頁>>代碼示例>>Java>>正文


Java ListResourceBundle.getString方法代碼示例

本文整理匯總了Java中java.util.ListResourceBundle.getString方法的典型用法代碼示例。如果您正苦於以下問題:Java ListResourceBundle.getString方法的具體用法?Java ListResourceBundle.getString怎麽用?Java ListResourceBundle.getString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.ListResourceBundle的用法示例。


在下文中一共展示了ListResourceBundle.getString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createMsg

import java.util.ListResourceBundle; //導入方法依賴的package包/類
/**
 * Creates a message from the specified key and replacement
 * arguments, localized to the given locale.
 *
 * @param fResourceBundle The resource bundle to use.
 * @param msgKey  The message key to use.
 * @param args      The arguments to be used as replacement text
 *                  in the message created.
 *
 * @return The formatted message string.
 */
public static final String createMsg(ListResourceBundle fResourceBundle,
      String msgKey, Object args[])  //throws Exception
{

  String fmsg = null;
  boolean throwex = false;
  String msg = null;

  if (msgKey != null)
    msg = fResourceBundle.getString(msgKey);

  if (msg == null)
  {
    msg = fResourceBundle.getString(BAD_CODE);
    throwex = true;
  }

  if (args != null)
  {
    try
    {

      // Do this to keep format from crying.
      // This is better than making a bunch of conditional
      // code all over the place.
      int n = args.length;

      for (int i = 0; i < n; i++)
      {
        if (null == args[i])
          args[i] = "";
      }

      fmsg = java.text.MessageFormat.format(msg, args);
    }
    catch (Exception e)
    {
      fmsg = fResourceBundle.getString(FORMAT_FAILED);
      fmsg += " " + msg;
    }
  }
  else
    fmsg = msg;

  if (throwex)
  {
    throw new RuntimeException(fmsg);
  }

  return fmsg;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:63,代碼來源:XMLMessages.java

示例2: createXPATHMsg

import java.util.ListResourceBundle; //導入方法依賴的package包/類
/**
 * Creates a message from the specified key and replacement arguments,
 * localized to the given locale.
 *
 * @param fResourceBundle The resource bundle to use.
 * @param msgKey The message key to use.
 * @param args The arguments to be used as replacement text in the message
 * created.
 *
 * @return The formatted message string.
 */
public static final String createXPATHMsg(ListResourceBundle fResourceBundle,
        String msgKey, Object args[]) //throws Exception
{

    String fmsg = null;
    boolean throwex = false;
    String msg = null;

    if (msgKey != null) {
        msg = fResourceBundle.getString(msgKey);
    }

    if (msg == null) {
        msg = fResourceBundle.getString(XPATHErrorResources.BAD_CODE);
        throwex = true;
    }

    if (args != null) {
        try {

            // Do this to keep format from crying.
            // This is better than making a bunch of conditional
            // code all over the place.
            int n = args.length;

            for (int i = 0; i < n; i++) {
                if (null == args[i]) {
                    args[i] = "";
                }
            }

            fmsg = java.text.MessageFormat.format(msg, args);
        } catch (Exception e) {
            fmsg = fResourceBundle.getString(XPATHErrorResources.FORMAT_FAILED);
            fmsg += " " + msg;
        }
    } else {
        fmsg = msg;
    }

    if (throwex) {
        throw new RuntimeException(fmsg);
    }

    return fmsg;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:58,代碼來源:XPATHMessages.java

示例3: createMsg

import java.util.ListResourceBundle; //導入方法依賴的package包/類
/**
  * Creates a message from the specified key and replacement
  * arguments, localized to the given locale.
  *
  * @param fResourceBundle The resource bundle to use.
  * @param msgKey  The message key to use.
  * @param args      The arguments to be used as replacement text
  *                  in the message created.
  *
  * @return The formatted message string.
  */
 public static final String createMsg(ListResourceBundle fResourceBundle,
String msgKey, Object args[])  //throws Exception
 {

   String fmsg = null;
   boolean throwex = false;
   String msg = null;

   if (msgKey != null)
     msg = fResourceBundle.getString(msgKey);

   if (msg == null)
   {
     msg = fResourceBundle.getString(BAD_CODE);
     throwex = true;
   }

   if (args != null)
   {
     try
     {

       // Do this to keep format from crying.
       // This is better than making a bunch of conditional
       // code all over the place.
       int n = args.length;

       for (int i = 0; i < n; i++)
       {
         if (null == args[i])
           args[i] = "";
       }

       fmsg = java.text.MessageFormat.format(msg, args);
     }
     catch (Exception e)
     {
       fmsg = fResourceBundle.getString(FORMAT_FAILED);
       fmsg += " " + msg;
     }
   }
   else
     fmsg = msg;

   if (throwex)
   {
     throw new RuntimeException(fmsg);
   }

   return fmsg;
 }
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:63,代碼來源:XMLMessages.java

示例4: createXPATHMsg

import java.util.ListResourceBundle; //導入方法依賴的package包/類
/**
 * Creates a message from the specified key and replacement
 * arguments, localized to the given locale.
 *
 * @param fResourceBundle The resource bundle to use.
 * @param msgKey  The message key to use.
 * @param args      The arguments to be used as replacement text
 *                  in the message created.
 *
 * @return The formatted message string.
 */
public static final String createXPATHMsg(ListResourceBundle fResourceBundle,
                                          String msgKey, Object args[])  //throws Exception
{

  String fmsg = null;
  boolean throwex = false;
  String msg = null;

  if (msgKey != null)
    msg = fResourceBundle.getString(msgKey); 

  if (msg == null)
  {
    msg = fResourceBundle.getString(XPATHErrorResources.BAD_CODE);
    throwex = true;
  }

  if (args != null)
  {
    try
    {

      // Do this to keep format from crying.
      // This is better than making a bunch of conditional
      // code all over the place.
      int n = args.length;

      for (int i = 0; i < n; i++)
      {
        if (null == args[i])
          args[i] = "";
      }

      fmsg = java.text.MessageFormat.format(msg, args);
    }
    catch (Exception e)
    {
      fmsg = fResourceBundle.getString(XPATHErrorResources.FORMAT_FAILED);
      fmsg += " " + msg;
    }
  }
  else
    fmsg = msg;

  if (throwex)
  {
    throw new RuntimeException(fmsg);
  }

  return fmsg;
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:63,代碼來源:XPATHMessages.java


注:本文中的java.util.ListResourceBundle.getString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。