Prevent an ArrayStoreException when doing magical number pluralizing if

the array of arguments happens to be a String[].


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3094 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2004-08-23 23:21:40 +00:00
parent 57a1cd774a
commit 5f4c4e82fd
@@ -1,5 +1,5 @@
//
// $Id: MessageBundle.java,v 1.26 2004/08/23 22:53:39 mdb Exp $
// $Id: MessageBundle.java,v 1.27 2004/08/23 23:21:40 ray Exp $
package com.threerings.util;
@@ -209,12 +209,18 @@ public class MessageBundle
if (msg == null) {
if (getResourceString(key + ".n", false) != null) {
try {
args[0] = new Integer(args[0].toString());
// args could be a String[], we need to turn it into
// an Object[]
Object[] newargs = new Object[args.length];
System.arraycopy(args, 1, newargs, 1, args.length - 1);
newargs[0] = new Integer(args[0].toString());
args = newargs;
msg = getResourceString(key + getSuffix(args));
} catch (Exception e) {
Log.warning("Failure doing automatic plural handling " +
"[bundle=" + _path + ", key=" + key +
", args=" + StringUtil.toString(args) + "].");
", args=" + StringUtil.toString(args) +
", error=" + e + "].");
}
} else {
@@ -236,15 +242,14 @@ public class MessageBundle
*/
protected String getSuffix (Object[] args)
{
String suffix = "";
if (args[0] instanceof Integer) {
switch (((Integer)args[0]).intValue()) {
case 0: suffix = ".0"; break;
case 1: suffix = ".1"; break;
default: suffix = ".n"; break;
case 0: return ".0";
case 1: return ".1";
default: return ".n";
}
}
return suffix;
return "";
}
/**