From 7cd5e55a82782390b4c219bd7405be10b293c601 Mon Sep 17 00:00:00 2001 From: mdb Date: Wed, 3 Mar 2004 11:44:09 +0000 Subject: [PATCH] Allow translation arguments to be objects which are then converted into strings. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1409 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../java/com/samskivert/text/MessageUtil.java | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/text/MessageUtil.java b/projects/samskivert/src/java/com/samskivert/text/MessageUtil.java index 0b9ddab5..9a41c016 100644 --- a/projects/samskivert/src/java/com/samskivert/text/MessageUtil.java +++ b/projects/samskivert/src/java/com/samskivert/text/MessageUtil.java @@ -1,5 +1,5 @@ // -// $Id: MessageUtil.java,v 1.2 2003/12/11 06:34:08 mdb Exp $ +// $Id: MessageUtil.java,v 1.3 2004/03/03 11:44:09 mdb Exp $ package com.samskivert.text; @@ -27,7 +27,7 @@ public class MessageUtil * attempt to translate this string when doing recursive translations * (see {@link #xlate}). */ - public static String taint (String text) + public static String taint (Object text) { return TAINT_CHAR + text; } @@ -36,7 +36,7 @@ public class MessageUtil * Composes a message key with an array of arguments. The message can * subsequently be translated in a single call using {@link #xlate}. */ - public static String compose (String key, String[] args) + public static String compose (String key, Object[] args) { StringBuffer buf = new StringBuffer(); buf.append(key); @@ -46,7 +46,7 @@ public class MessageUtil buf.append('|'); } // escape the string while adding to the buffer - String arg = (args[i] == null) ? "" : args[i]; + String arg = (args[i] == null) ? "" : String.valueOf(args[i]); int alength = arg.length(); for (int p = 0; p < alength; p++) { char ch = arg.charAt(p); @@ -104,71 +104,71 @@ public class MessageUtil } /** - * A convenience method for calling {@link #compose(String,String[])} + * A convenience method for calling {@link #compose(String,Object[])} * with a single argument. */ - public static String compose (String key, String arg) + public static String compose (String key, Object arg) { - return compose(key, new String[] { arg }); + return compose(key, new Object[] { arg }); } /** - * A convenience method for calling {@link #compose(String,String[])} + * A convenience method for calling {@link #compose(String,Object[])} * with two arguments. */ - public static String compose (String key, String arg1, String arg2) + public static String compose (String key, Object arg1, Object arg2) { - return compose(key, new String[] { arg1, arg2 }); + return compose(key, new Object[] { arg1, arg2 }); } /** - * A convenience method for calling {@link #compose(String,String[])} + * A convenience method for calling {@link #compose(String,Object[])} * with three arguments. */ public static String compose ( - String key, String arg1, String arg2, String arg3) + String key, Object arg1, Object arg2, Object arg3) { - return compose(key, new String[] { arg1, arg2, arg3 }); + return compose(key, new Object[] { arg1, arg2, arg3 }); } /** - * A convenience method for calling {@link #compose(String,String[])} + * A convenience method for calling {@link #compose(String,Object[])} * with a single argument that will be automatically tainted (see * {@link #taint}). */ - public static String tcompose (String key, String arg) + public static String tcompose (String key, Object arg) { - return compose(key, new String[] { taint(arg) }); + return compose(key, new Object[] { taint(arg) }); } /** - * A convenience method for calling {@link #compose(String,String[])} + * A convenience method for calling {@link #compose(String,Object[])} * with two arguments that will be automatically tainted (see {@link * #taint}). */ - public static String tcompose (String key, String arg1, String arg2) + public static String tcompose (String key, Object arg1, Object arg2) { - return compose(key, new String[] { taint(arg1), taint(arg2) }); + return compose(key, new Object[] { taint(arg1), taint(arg2) }); } /** - * A convenience method for calling {@link #compose(String,String[])} + * A convenience method for calling {@link #compose(String,Object[])} * with three arguments that will be automatically tainted (see {@link * #taint}). */ public static String tcompose ( - String key, String arg1, String arg2, String arg3) + String key, Object arg1, Object arg2, Object arg3) { - return compose(key, new String[] { + return compose(key, new Object[] { taint(arg1), taint(arg2), taint(arg3) }); } /** - * A convenience method for calling {@link #compose(String,String[])} + * A convenience method for calling {@link #compose(String,Object[])} * with an array of arguments that will be automatically tainted (see * {@link #taint}). */ - public static String tcompose (String key, String[] args) + public static String tcompose (String key, Object[] args) { int acount = args.length; String[] targs = new String[acount];