summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/certsrv/base/MessageFormatter.java
diff options
context:
space:
mode:
Diffstat (limited to 'base/common/src/com/netscape/certsrv/base/MessageFormatter.java')
-rw-r--r--base/common/src/com/netscape/certsrv/base/MessageFormatter.java102
1 files changed, 49 insertions, 53 deletions
diff --git a/base/common/src/com/netscape/certsrv/base/MessageFormatter.java b/base/common/src/com/netscape/certsrv/base/MessageFormatter.java
index 40275b516..f573a227e 100644
--- a/base/common/src/com/netscape/certsrv/base/MessageFormatter.java
+++ b/base/common/src/com/netscape/certsrv/base/MessageFormatter.java
@@ -88,67 +88,63 @@ public class MessageFormatter {
String localizedFormat = null;
try {
- try {
- // if you are worried about the efficiency of the
- // following line, dont worry. ResourceBundle has
- // an internal cache. So resource bundle wont be
- // instantiated everytime you call toString().
+ // if you are worried about the efficiency of the
+ // following line, dont worry. ResourceBundle has
+ // an internal cache. So resource bundle wont be
+ // instantiated everytime you call toString().
- localizedFormat = ResourceBundle.getBundle(
- resourceBundleBaseName, locale).getString(formatString);
- } catch (MissingResourceException e) {
- return formatString;
+ localizedFormat = ResourceBundle.getBundle(
+ resourceBundleBaseName, locale).getString(formatString);
+ } catch (MissingResourceException e) {
+ return formatString;
- }
- Object[] localizedParams = params;
- Object[] localeArg = null;
-
- if (params != null) {
- for (int i = 0; i < params.length; ++i) {
- if (!(params[i] instanceof String) ||
- !(params[i] instanceof Date) ||
- !(params[i] instanceof Number)) {
- if (localizedParams == params) {
+ }
+ Object[] localizedParams = params;
+ Object[] localeArg = null;
+
+ if (params != null) {
+ for (int i = 0; i < params.length; ++i) {
+ if (!(params[i] instanceof String) ||
+ !(params[i] instanceof Date) ||
+ !(params[i] instanceof Number)) {
+ if (localizedParams == params) {
+
+ // only done once
+ // NB if the following variant of cloning code is used
+ // localizedParams = (Object [])mParams.clone();
+ // it causes ArrayStoreException in
+ // localizedParams[i] = params[i].toString();
+ // below
+
+ localizedParams = new Object[params.length];
+ System.arraycopy(params, 0, localizedParams, 0,
+ params.length);
+ }
+ try {
+ Method toStringMethod = params[i].getClass().getMethod(
+ "toString", toStringSignature);
+ if (localeArg == null) {
// only done once
- // NB if the following variant of cloning code is used
- // localizedParams = (Object [])mParams.clone();
- // it causes ArrayStoreException in
- // localizedParams[i] = params[i].toString();
- // below
-
- localizedParams = new Object[params.length];
- System.arraycopy(params, 0, localizedParams, 0,
- params.length);
- }
- try {
- Method toStringMethod = params[i].getClass().getMethod(
- "toString", toStringSignature);
-
- if (localeArg == null) {
- // only done once
- localeArg = new Object[] { locale };
- }
- localizedParams[i] = toStringMethod.invoke(
- params[i], localeArg);
- } catch (Exception e) {
- // no method for localization, fall back
- localizedParams[i] = params[i].toString();
+ localeArg = new Object[] { locale };
}
+ localizedParams[i] = toStringMethod.invoke(
+ params[i], localeArg);
+ } catch (Exception e) {
+ // no method for localization, fall back
+ localizedParams[i] = params[i].toString();
}
}
}
- try {
- // XXX - runtime exception may be raised by the following function
- MessageFormat format = new MessageFormat(localizedFormat);
-
- return format.format(localizedParams);
- } catch (IllegalArgumentException e) {
- // XXX - for now, we just print the unformatted message
- // if the exception is raised
- return localizedFormat;
- }
- } catch (Exception e) {
+ }
+ try {
+ // XXX - runtime exception may be raised by the following function
+ MessageFormat format = new MessageFormat(localizedFormat);
+
+ return format.format(localizedParams);
+ } catch (IllegalArgumentException e) {
+ // XXX - for now, we just print the unformatted message
+ // if the exception is raised
return localizedFormat;
}
}