<div dir="ltr">Hi Ceki.<br><br>You forgot the double[] in your last commit.<br><br>Regards, Joern.<br><br><div class="gmail_quote">On Thu, Jul 31, 2008 at 10:51 PM,  <span dir="ltr">&lt;<a href="mailto:ceki@slf4j.org">ceki@slf4j.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Author: ceki<br>
Date: Thu Jul 31 22:51:04 2008<br>
New Revision: 1086<br>
<br>
Modified:<br>
 &nbsp; slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers/MessageFormatter.java<br>
 &nbsp; slf4j/trunk/slf4j-api/src/test/java/org/slf4j/helpers/MessageFormatterTest.java<br>
<br>
Log:<br>
- add support for array values in parameters<br>
<br>
 &nbsp;For example,<br>
<br>
 &nbsp;log.debug(&quot;a:{},i:{}&quot;, &quot;A&quot;, new int[] {1, 2}});<br>
 &nbsp;will print as &quot;a:A,i:[1, 2]&quot; instead of &quot;a:A,i:[I@6ca1c&quot; as previously<br>
<br>
 &nbsp;log.debug(&quot;a:{},b:{},i:{},&quot;, new Object[] {&quot;A&quot;, &quot;B&quot;, new int[] {1, 2}});<br>
 &nbsp;will print as &quot;a:A,b:B,i:[1, 2]&quot; instead of &quot;a:A,b:B,i:[I@90c78&quot; as previously<br>
<br>
 &nbsp;This enhancement was proposed by &quot;lizongbo&quot;<br>
<br>
Modified: slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers/MessageFormatter.java<br>
==============================================================================<br>
--- slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers/MessageFormatter.java (original)<br>
+++ slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers/MessageFormatter.java Thu Jul 31 22:51:04 2008<br>
@@ -24,12 +24,20 @@<br>
<br>
&nbsp;package org.slf4j.helpers;<br>
<br>
+import java.util.Arrays;<br>
+<br>
+// contributors: lizongbo<br>
+<br>
&nbsp;/**<br>
 &nbsp;* Formats messages according to very simple substitution rules. Substitutions<br>
 &nbsp;* can be made 1, 2 or more arguments.<br>
 &nbsp;* &lt;p&gt;<br>
 &nbsp;* For example,<br>
- * &lt;pre&gt;MessageFormatter.format(&amp;quot;Hi {}.&amp;quot;, &amp;quot;there&amp;quot;);&lt;/pre&gt;<br>
+ *<br>
+ * &lt;pre&gt;<br>
+ * MessageFormatter.format(&amp;quot;Hi {}.&amp;quot;, &amp;quot;there&amp;quot;);<br>
+ * &lt;/pre&gt;<br>
+ *<br>
 &nbsp;* will return the string &quot;Hi there.&quot;.<br>
 &nbsp;* &lt;p&gt;<br>
 &nbsp;* The {} pair is called the &lt;em&gt;formatting anchor&lt;/em&gt;. It serves to<br>
@@ -40,14 +48,22 @@<br>
 &nbsp;* pattern itself but do not want them to be interpreted as a formatting<br>
 &nbsp;* anchors, you can escape the &#39;{&#39; character with &#39;\&#39;, that is the backslash<br>
 &nbsp;* character. Only the &#39;{&#39; character should be escaped. There is no need to<br>
- * escape the &#39;}&#39; character. For example,<br>
- * &lt;pre&gt;MessageFormatter.format(&amp;quot;Set \\{1,2,3} is not equal to {}.&amp;quot;, &amp;quot;1,2&amp;quot;);&lt;/pre&gt;<br>
- * will return the string &quot;Set {1,2,3} is not equal to 1,2.&quot;.<br>
+ * escape the &#39;}&#39; character. For example,<br>
+ *<br>
+ * &lt;pre&gt;<br>
+ * MessageFormatter.format(&amp;quot;Set \\{1,2,3} is not equal to {}.&amp;quot;, &amp;quot;1,2&amp;quot;);<br>
+ * &lt;/pre&gt;<br>
+ *<br>
+ * will return the string &quot;Set {1,2,3} is not equal to 1,2.&quot;.<br>
 &nbsp;*<br>
 &nbsp;* &lt;p&gt;<br>
- * The escaping behavior just described can be overridden by<br>
- * escaping the escape character &#39;\&#39;. Calling<br>
- * &lt;pre&gt;MessageFormatter.format(&amp;quot;File name is C:\\\\{}.&amp;quot;, &amp;quot;file.zip&amp;quot;);&lt;/pre&gt;<br>
+ * The escaping behavior just described can be overridden by escaping the escape<br>
+ * character &#39;\&#39;. Calling<br>
+ *<br>
+ * &lt;pre&gt;<br>
+ * MessageFormatter.format(&amp;quot;File name is C:\\\\{}.&amp;quot;, &amp;quot;file.zip&amp;quot;);<br>
+ * &lt;/pre&gt;<br>
+ *<br>
 &nbsp;* will return the string &quot;File name is C:\file.zip&quot;.<br>
 &nbsp;*<br>
 &nbsp;* &lt;p&gt;<br>
@@ -60,7 +76,7 @@<br>
 &nbsp; static final char DELIM_START = &#39;{&#39;;<br>
 &nbsp; static final char DELIM_STOP = &#39;}&#39;;<br>
 &nbsp; private static final char ESCAPE_CHAR = &#39;\\&#39;;<br>
-<br>
+<br>
 &nbsp; /**<br>
 &nbsp; &nbsp;* Performs single argument substitution for the &#39;messagePattern&#39; passed as<br>
 &nbsp; &nbsp;* parameter.<br>
@@ -75,9 +91,10 @@<br>
 &nbsp; &nbsp;* &lt;p&gt;<br>
 &nbsp; &nbsp;*<br>
 &nbsp; &nbsp;* @param messagePattern<br>
- &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;The message pattern which will be parsed and formatted<br>
+ &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;The message pattern which will be parsed and formatted<br>
 &nbsp; &nbsp;* @param argument<br>
- &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;The argument to be substituted in place of the formatting anchor<br>
+ &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;The argument to be substituted in place of the formatting<br>
+ &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;anchor<br>
 &nbsp; &nbsp;* @return The formatted message<br>
 &nbsp; &nbsp;*/<br>
 &nbsp; public static String format(String messagePattern, Object arg) {<br>
@@ -98,13 +115,13 @@<br>
 &nbsp; &nbsp;* will return the string &quot;Hi Alice. My name is Bob.&quot;.<br>
 &nbsp; &nbsp;*<br>
 &nbsp; &nbsp;* @param messagePattern<br>
- &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;The message pattern which will be parsed and formatted<br>
+ &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;The message pattern which will be parsed and formatted<br>
 &nbsp; &nbsp;* @param arg1<br>
- &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;The argument to be substituted in place of the first formatting<br>
- &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;anchor<br>
+ &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;The argument to be substituted in place of the first<br>
+ &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;formatting anchor<br>
 &nbsp; &nbsp;* @param arg2<br>
- &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;The argument to be substituted in place of the second formatting<br>
- &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;anchor<br>
+ &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;The argument to be substituted in place of the second<br>
+ &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;formatting anchor<br>
 &nbsp; &nbsp;* @return The formatted message<br>
 &nbsp; &nbsp;*/<br>
 &nbsp; public static String format(String messagePattern, Object arg1, Object arg2) {<br>
@@ -117,10 +134,10 @@<br>
 &nbsp; &nbsp;* arguments can be passed in an array.<br>
 &nbsp; &nbsp;*<br>
 &nbsp; &nbsp;* @param messagePattern<br>
- &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;The message pattern which will be parsed and formatted<br>
+ &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;The message pattern which will be parsed and formatted<br>
 &nbsp; &nbsp;* @param argArray<br>
- &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;An array of arguments to be substituted in place of formatting<br>
- &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;anchors<br>
+ &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;An array of arguments to be substituted in place of<br>
+ &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;formatting anchors<br>
 &nbsp; &nbsp;* @return The formatted message<br>
 &nbsp; &nbsp;*/<br>
 &nbsp; public static String arrayFormat(String messagePattern, Object[] argArray) {<br>
@@ -131,10 +148,10 @@<br>
 &nbsp; &nbsp; int len = messagePattern.length();<br>
 &nbsp; &nbsp; int j = messagePattern.indexOf(DELIM_START);<br>
<br>
- &nbsp; &nbsp;if(argArray == null) {<br>
+ &nbsp; &nbsp;if (argArray == null) {<br>
 &nbsp; &nbsp; &nbsp; return messagePattern;<br>
 &nbsp; &nbsp; }<br>
-<br>
+<br>
 &nbsp; &nbsp; StringBuffer sbuf = new StringBuffer(messagePattern.length() + 50);<br>
<br>
 &nbsp; &nbsp; for (int L = 0; L &lt; argArray.length; L++) {<br>
@@ -154,7 +171,7 @@<br>
 &nbsp; &nbsp; &nbsp; &nbsp; char delimStop = messagePattern.charAt(j + 1);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; if (isEscapedDelimeter(messagePattern, j)) {<br>
- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(!isDoubleEscaped(messagePattern, j)) {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!isDoubleEscaped(messagePattern, j)) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; L--; // DELIM_START was escaped, thus should not be incremented<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sbuf.append(messagePattern.substring(i, j - 1));<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sbuf.append(DELIM_START);<br>
@@ -163,8 +180,9 @@<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // The escape character preceding the delemiter start is<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // itself escaped: &quot;abc x:\\{}&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // we have to consume one backward slash<br>
- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sbuf.append(messagePattern.substring(i, j-1));<br>
- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sbuf.append(argArray[L]);<br>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sbuf.append(messagePattern.substring(i, j - 1));<br>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;appendParameter(sbuf, argArray[L]);<br>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// sbuf.append(argArray[L]);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i = j + 2;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
 &nbsp; &nbsp; &nbsp; &nbsp; } else if ((delimStop != DELIM_STOP)) {<br>
@@ -174,7 +192,7 @@<br>
 &nbsp; &nbsp; &nbsp; &nbsp; } else {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // normal case<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sbuf.append(messagePattern.substring(i, j));<br>
- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sbuf.append(argArray[L]);<br>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;appendParameter(sbuf, argArray[L]);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i = j + 2;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; }<br>
 &nbsp; &nbsp; &nbsp; }<br>
@@ -206,4 +224,31 @@<br>
 &nbsp; &nbsp; &nbsp; return false;<br>
 &nbsp; &nbsp; }<br>
 &nbsp; }<br>
+<br>
+ &nbsp;// special treatment of array values was suggested by &#39;lizongbo&#39;<br>
+ &nbsp;private static void appendParameter(StringBuffer sbuf, Object o) {<br>
+ &nbsp; &nbsp;if (o != null &amp;&amp; o.getClass().isArray()) {<br>
+ &nbsp; &nbsp; &nbsp;// check for primitive arrays because they unfortunately<br>
+ &nbsp; &nbsp; &nbsp;// cannot be cast to Object[]<br>
+ &nbsp; &nbsp; &nbsp;if (o instanceof boolean[]) {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;sbuf.append(Arrays.toString((boolean[]) o));<br>
+ &nbsp; &nbsp; &nbsp;} else if (o instanceof byte[]) {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;sbuf.append(Arrays.toString((byte[]) o));<br>
+ &nbsp; &nbsp; &nbsp;} else if (o instanceof char[]) {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;sbuf.append(Arrays.toString((char[]) o));<br>
+ &nbsp; &nbsp; &nbsp;} else if (o instanceof short[]) {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;sbuf.append(Arrays.toString((short[]) o));<br>
+ &nbsp; &nbsp; &nbsp;} else if (o instanceof int[]) {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;sbuf.append(Arrays.toString((int[]) o));<br>
+ &nbsp; &nbsp; &nbsp;} else if (o instanceof long[]) {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;sbuf.append(Arrays.toString((long[]) o));<br>
+ &nbsp; &nbsp; &nbsp;} else if (o instanceof float[]) {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;sbuf.append(Arrays.toString((float[]) o));<br>
+ &nbsp; &nbsp; &nbsp;} else {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;sbuf.append(Arrays.toString((Object[]) o));<br>
+ &nbsp; &nbsp; &nbsp;}<br>
+ &nbsp; &nbsp;} else {<br>
+ &nbsp; &nbsp; &nbsp;sbuf.append(o);<br>
+ &nbsp; &nbsp;}<br>
+ &nbsp;}<br>
&nbsp;}<br>
<br>
Modified: slf4j/trunk/slf4j-api/src/test/java/org/slf4j/helpers/MessageFormatterTest.java<br>
==============================================================================<br>
--- slf4j/trunk/slf4j-api/src/test/java/org/slf4j/helpers/MessageFormatterTest.java &nbsp; &nbsp; (original)<br>
+++ slf4j/trunk/slf4j-api/src/test/java/org/slf4j/helpers/MessageFormatterTest.java &nbsp; &nbsp; Thu Jul 31 22:51:04 2008<br>
@@ -33,56 +33,59 @@<br>
<br>
&nbsp;package org.slf4j.helpers;<br>
<br>
+import java.util.Arrays;<br>
+<br>
&nbsp;import org.slf4j.helpers.MessageFormatter;<br>
<br>
&nbsp;import junit.framework.TestCase;<br>
<br>
-<br>
&nbsp;/**<br>
 &nbsp;* @author Ceki Gulcu<br>
- *<br>
+ *<br>
 &nbsp;*/<br>
&nbsp;public class MessageFormatterTest extends TestCase {<br>
-<br>
+<br>
 &nbsp; Integer i1 = new Integer(1);<br>
 &nbsp; Integer i2 = new Integer(2);<br>
 &nbsp; Integer i3 = new Integer(3);<br>
-<br>
+<br>
 &nbsp; public void testNull() {<br>
 &nbsp; &nbsp; String result;<br>
 &nbsp; &nbsp; result = MessageFormatter.format(null, i1);<br>
 &nbsp; &nbsp; assertEquals(null, result);<br>
 &nbsp; }<br>
-<br>
+<br>
 &nbsp; public void testNullParam() {<br>
 &nbsp; &nbsp; String result;<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;Value is {}.&quot;, null);<br>
 &nbsp; &nbsp; assertEquals(&quot;Value is null.&quot;, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;Val1 is {}, val2 is {}.&quot;, null, null);<br>
 &nbsp; &nbsp; assertEquals(&quot;Val1 is null, val2 is null.&quot;, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;Val1 is {}, val2 is {}.&quot;, i1, null);<br>
 &nbsp; &nbsp; assertEquals(&quot;Val1 is 1, val2 is null.&quot;, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;Val1 is {}, val2 is {}.&quot;, null, i2);<br>
 &nbsp; &nbsp; assertEquals(&quot;Val1 is null, val2 is 2.&quot;, result);<br>
-<br>
- &nbsp; &nbsp;result = MessageFormatter.arrayFormat(&quot;Val1 is {}, val2 is {}, val3 is {}&quot;, new Integer[]{null, null, null});<br>
+<br>
+ &nbsp; &nbsp;result = MessageFormatter.arrayFormat(&quot;Val1 is {}, val2 is {}, val3 is {}&quot;,<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;new Integer[] { null, null, null });<br>
 &nbsp; &nbsp; assertEquals(&quot;Val1 is null, val2 is null, val3 is null&quot;, result);<br>
-<br>
- &nbsp; &nbsp;result = MessageFormatter.arrayFormat(&quot;Val1 is {}, val2 is {}, val3 is {}&quot;, new Integer[]{null, i2, i3});<br>
+<br>
+ &nbsp; &nbsp;result = MessageFormatter.arrayFormat(&quot;Val1 is {}, val2 is {}, val3 is {}&quot;,<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;new Integer[] { null, i2, i3 });<br>
 &nbsp; &nbsp; assertEquals(&quot;Val1 is null, val2 is 2, val3 is 3&quot;, result);<br>
-<br>
- &nbsp; &nbsp;result = MessageFormatter.arrayFormat(&quot;Val1 is {}, val2 is {}, val3 is {}&quot;, new Integer[]{null, null, i3});<br>
+<br>
+ &nbsp; &nbsp;result = MessageFormatter.arrayFormat(&quot;Val1 is {}, val2 is {}, val3 is {}&quot;,<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;new Integer[] { null, null, i3 });<br>
 &nbsp; &nbsp; assertEquals(&quot;Val1 is null, val2 is null, val3 is 3&quot;, result);<br>
 &nbsp; }<br>
-<br>
-<br>
+<br>
 &nbsp; public void testOneParameter() {<br>
 &nbsp; &nbsp; String result;<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;Value is {}.&quot;, i3);<br>
 &nbsp; &nbsp; assertEquals(&quot;Value is 3.&quot;, result);<br>
<br>
@@ -94,13 +97,13 @@<br>
<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;No subst&quot;, i3);<br>
 &nbsp; &nbsp; assertEquals(&quot;No subst&quot;, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;Incorrect {subst&quot;, i3);<br>
 &nbsp; &nbsp; assertEquals(&quot;Incorrect {subst&quot;, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;Value is \\{bla} {}&quot;, i3);<br>
 &nbsp; &nbsp; assertEquals(&quot;Value is {bla} 3&quot;, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;Escaped \\{} subst&quot;, i3);<br>
 &nbsp; &nbsp; assertEquals(&quot;Escaped {} subst&quot;, result);<br>
<br>
@@ -109,51 +112,52 @@<br>
<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;\\{}Escaped&quot;, i3);<br>
 &nbsp; &nbsp; assertEquals(&quot;{}Escaped&quot;, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;File name is \\{{}}.&quot;, &quot;App folder.zip&quot;);<br>
 &nbsp; &nbsp; assertEquals(&quot;File name is {App folder.zip}.&quot;, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; // escaping the escape character<br>
- &nbsp; &nbsp;result = MessageFormatter.format(&quot;File name is C:\\\\{}.&quot;, &quot;App folder.zip&quot;);<br>
+ &nbsp; &nbsp;result = MessageFormatter<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;.format(&quot;File name is C:\\\\{}.&quot;, &quot;App folder.zip&quot;);<br>
 &nbsp; &nbsp; assertEquals(&quot;File name is C:\\App folder.zip.&quot;, result);<br>
 &nbsp; }<br>
-<br>
+<br>
 &nbsp; public void testTwoParameters() {<br>
 &nbsp; &nbsp; String result;<br>
<br>
-<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;Value {} is smaller than {}.&quot;, i1, i2);<br>
 &nbsp; &nbsp; assertEquals(&quot;Value 1 is smaller than 2.&quot;, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;Value {} is smaller than {}&quot;, i1, i2);<br>
 &nbsp; &nbsp; assertEquals(&quot;Value 1 is smaller than 2&quot;, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;{}{}&quot;, i1, i2);<br>
 &nbsp; &nbsp; assertEquals(&quot;12&quot;, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;Val1={}, Val2={&quot;, i1, i2);<br>
 &nbsp; &nbsp; assertEquals(&quot;Val1=1, Val2={&quot;, result);<br>
<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;Value {} is smaller than \\{}&quot;, i1, i2);<br>
 &nbsp; &nbsp; assertEquals(&quot;Value 1 is smaller than {}&quot;, result);<br>
-<br>
- &nbsp; &nbsp;result = MessageFormatter.format(&quot;Value {} is smaller than \\{} tail&quot;, i1, i2);<br>
- &nbsp; &nbsp;assertEquals(&quot;Value 1 is smaller than {} tail&quot;, result);<br>
+<br>
+ &nbsp; &nbsp;result = MessageFormatter.format(&quot;Value {} is smaller than \\{} tail&quot;, i1,<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;i2);<br>
+ &nbsp; &nbsp;assertEquals(&quot;Value 1 is smaller than {} tail&quot;, result);<br>
<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;Value {} is smaller than \\{&quot;, i1, i2);<br>
- &nbsp; &nbsp;assertEquals(&quot;Value 1 is smaller than \\{&quot;, result);<br>
-<br>
- &nbsp; &nbsp;result = MessageFormatter.format(&quot;Value {} is smaller than \\{tail&quot;, i1, i2);<br>
- &nbsp; &nbsp;assertEquals(&quot;Value 1 is smaller than {tail&quot;, result);<br>
-<br>
-<br>
+ &nbsp; &nbsp;assertEquals(&quot;Value 1 is smaller than \\{&quot;, result);<br>
+<br>
+ &nbsp; &nbsp;result = MessageFormatter<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;.format(&quot;Value {} is smaller than \\{tail&quot;, i1, i2);<br>
+ &nbsp; &nbsp;assertEquals(&quot;Value 1 is smaller than {tail&quot;, result);<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.format(&quot;Value \\{} is smaller than {}&quot;, i1, i2);<br>
- &nbsp; &nbsp;assertEquals(&quot;Value {} is smaller than 1&quot;, result);<br>
+ &nbsp; &nbsp;assertEquals(&quot;Value {} is smaller than 1&quot;, result);<br>
 &nbsp; }<br>
-<br>
+<br>
 &nbsp; public void testNullArray() {<br>
 &nbsp; &nbsp; String result;<br>
-<br>
+<br>
 &nbsp; &nbsp; String msg0 = &quot;msg0&quot;;<br>
 &nbsp; &nbsp; String msg1 = &quot;msg1 {}&quot;;<br>
 &nbsp; &nbsp; String msg2 = &quot;msg2 {} {}&quot;;<br>
@@ -163,44 +167,69 @@<br>
<br>
 &nbsp; &nbsp; result = MessageFormatter.arrayFormat(msg0, args);<br>
 &nbsp; &nbsp; assertEquals(msg0, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.arrayFormat(msg1, args);<br>
 &nbsp; &nbsp; assertEquals(msg1, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.arrayFormat(msg2, args);<br>
 &nbsp; &nbsp; assertEquals(msg2, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.arrayFormat(msg3, args);<br>
 &nbsp; &nbsp; assertEquals(msg3, result);<br>
 &nbsp; }<br>
- &nbsp;public void testArray() {<br>
+<br>
+ &nbsp;// tests the case when the parameters are supplied in a single array<br>
+ &nbsp;public void testArrayFormat() {<br>
 &nbsp; &nbsp; String result;<br>
<br>
- &nbsp; &nbsp;Integer[] ia = new Integer[] {i1, i2, i3};<br>
+ &nbsp; &nbsp;Integer[] ia = new Integer[] { i1, i2, i3 };<br>
<br>
- &nbsp; &nbsp;result = MessageFormatter.arrayFormat(&quot;Value {} is smaller than {} and {}.&quot;, ia);<br>
+ &nbsp; &nbsp;result = MessageFormatter.arrayFormat(<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;&quot;Value {} is smaller than {} and {}.&quot;, ia);<br>
 &nbsp; &nbsp; assertEquals(&quot;Value 1 is smaller than 2 and 3.&quot;, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.arrayFormat(&quot;{}{}{}&quot;, ia);<br>
 &nbsp; &nbsp; assertEquals(&quot;123&quot;, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.arrayFormat(&quot;Value {} is smaller than {}.&quot;, ia);<br>
 &nbsp; &nbsp; assertEquals(&quot;Value 1 is smaller than 2.&quot;, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.arrayFormat(&quot;Value {} is smaller than {}&quot;, ia);<br>
 &nbsp; &nbsp; assertEquals(&quot;Value 1 is smaller than 2&quot;, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.arrayFormat(&quot;Val={}, {, Val={}&quot;, ia);<br>
 &nbsp; &nbsp; assertEquals(&quot;Val=1, {, Val={}&quot;, result);<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.arrayFormat(&quot;Val={}, \\{, Val={}&quot;, ia);<br>
 &nbsp; &nbsp; assertEquals(&quot;Val=1, {, Val=2&quot;, result);<br>
-<br>
-<br>
+<br>
 &nbsp; &nbsp; result = MessageFormatter.arrayFormat(&quot;Val1={}, Val2={&quot;, ia);<br>
 &nbsp; &nbsp; assertEquals(&quot;Val1=1, Val2={&quot;, result);<br>
-<br>
+ &nbsp;}<br>
+<br>
+ &nbsp;public void testArrayValues() {<br>
+<br>
+ &nbsp; &nbsp;String result;<br>
+<br>
+ &nbsp; &nbsp;Integer p0 = i1;<br>
+ &nbsp; &nbsp;Integer[] p1 = new Integer[] { i2, i3 };<br>
+<br>
+ &nbsp; &nbsp;System.out.println(&quot;[&quot; + Arrays.toString(new int[] { 1, 2 }) + &quot;]&quot;);<br>
+<br>
+ &nbsp; &nbsp;result = MessageFormatter.format(&quot;{}{}&quot;, p0, p1);<br>
+ &nbsp; &nbsp;assertEquals(p0 + Arrays.toString(p1), result);<br>
+<br>
+ &nbsp; &nbsp;{<br>
+ &nbsp; &nbsp; &nbsp;Object[] pa = new Object[] { &quot;a&quot;, p1 };<br>
+ &nbsp; &nbsp; &nbsp;result = MessageFormatter.arrayFormat(&quot;{}{}&quot;, pa);<br>
+ &nbsp; &nbsp; &nbsp;assertEquals(&quot;a&quot; + Arrays.toString(p1), result);<br>
+ &nbsp; &nbsp;}<br>
<br>
+ &nbsp; &nbsp;{<br>
+ &nbsp; &nbsp; &nbsp;Object[] pa = new Object[] { &quot;a&quot;, new int[] { 1, 2 } };<br>
+ &nbsp; &nbsp; &nbsp;result = MessageFormatter.arrayFormat(&quot;{}{}&quot;, pa);<br>
+ &nbsp; &nbsp; &nbsp;assertEquals(&quot;a&quot; + Arrays.toString(new int[] { 1, 2 }), result);<br>
+ &nbsp; &nbsp;}<br>
 &nbsp; }<br>
<br>
&nbsp;}<br>
_______________________________________________<br>
dev mailing list<br>
<a href="mailto:dev@slf4j.org">dev@slf4j.org</a><br>
<a href="http://www.slf4j.org/mailman/listinfo/dev" target="_blank">http://www.slf4j.org/mailman/listinfo/dev</a><br>
</blockquote></div><br></div>