本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}