Return-Path: Delivered-To: apmail-incubator-click-commits-archive@locus.apache.org Received: (qmail 21472 invoked from network); 4 Jan 2009 21:19:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Jan 2009 21:19:50 -0000 Received: (qmail 68695 invoked by uid 500); 4 Jan 2009 21:19:50 -0000 Delivered-To: apmail-incubator-click-commits-archive@incubator.apache.org Received: (qmail 68679 invoked by uid 500); 4 Jan 2009 21:19:50 -0000 Mailing-List: contact click-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: click-dev@incubator.apache.org Delivered-To: mailing list click-commits@incubator.apache.org Received: (qmail 68665 invoked by uid 99); 4 Jan 2009 21:19:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Jan 2009 13:19:50 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Jan 2009 21:19:49 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7787F238899E; Sun, 4 Jan 2009 13:19:29 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r731361 - /incubator/click/trunk/click/framework/src/net/sf/click/util/Format.java Date: Sun, 04 Jan 2009 21:19:29 -0000 To: click-commits@incubator.apache.org From: sabob@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090104211929.7787F238899E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sabob Date: Sun Jan 4 13:19:28 2009 New Revision: 731361 URL: http://svn.apache.org/viewvc?rev=731361&view=rev Log: added MessageFormat support. CLK-474 Modified: incubator/click/trunk/click/framework/src/net/sf/click/util/Format.java Modified: incubator/click/trunk/click/framework/src/net/sf/click/util/Format.java URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/net/sf/click/util/Format.java?rev=731361&r1=731360&r2=731361&view=diff ============================================================================== --- incubator/click/trunk/click/framework/src/net/sf/click/util/Format.java (original) +++ incubator/click/trunk/click/framework/src/net/sf/click/util/Format.java Sun Jan 4 13:19:28 2009 @@ -21,9 +21,11 @@ import java.io.Serializable; import java.text.DateFormat; import java.text.DecimalFormat; +import java.text.MessageFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.List; import java.util.Locale; import net.sf.click.Context; @@ -682,6 +684,46 @@ } /** + * Return a formatted string using the given message pattern and argument. + * See {@link java.text.MessageFormat} for information on the message + * pattern string. + * + * @param pattern the message pattern + * @param argument the message argument + * @return the formatted string + */ + public String message(String pattern, Object argument) { + return message(pattern, new Object[] { argument }); + } + + /** + * Return a formatted string using the given message pattern and arguments. + * See {@link java.text.MessageFormat} for information on the message + * pattern string. + * + * @param pattern the message pattern + * @param arguments the message arguments + * @return the formatted string + */ + public String message(String pattern, Object[] arguments) { + MessageFormat format = new MessageFormat(pattern, getLocale()); + return format.format(arguments, new StringBuffer(), null).toString(); + } + + /** + * Return a formatted string using the given message pattern and arguments. + * See {@link java.text.MessageFormat} for information on the message + * pattern string. + * + * @param pattern the message pattern + * @param arguments list of message arguments + * @return the formatted string + */ + public String message(String pattern, List arguments) { + return message(pattern, arguments.toArray()); + } + + /** * Return a percentage formatted number string using number. *

* If the number is null this method will return the