@Test public void testArrayThrowable() { FormattingTuple ft; Throwable t = new Throwable(); Object[] ia = new Object[] { i1, i2, i3, t }; Object[] iaWitness = new Object[] { i1, i2, i3 }; ft = MessageFormatter.arrayFormat("Value {} is smaller than {} and {}.", ia); assertEquals("Value 1 is smaller than 2 and 3.", ft.getMessage()); assertTrue(Arrays.equals(iaWitness, ft.getArgArray())); assertEquals(t, ft.getThrowable()); ft = MessageFormatter.arrayFormat("{}{}{}", ia); assertEquals("123", ft.getMessage()); assertTrue(Arrays.equals(iaWitness, ft.getArgArray())); assertEquals(t, ft.getThrowable()); ft = MessageFormatter.arrayFormat("Value {} is smaller than {}.", ia); assertEquals("Value 1 is smaller than 2.", ft.getMessage()); assertTrue(Arrays.equals(iaWitness, ft.getArgArray())); assertEquals(t, ft.getThrowable()); ft = MessageFormatter.arrayFormat("Value {} is smaller than {}", ia); assertEquals("Value 1 is smaller than 2", ft.getMessage()); assertTrue(Arrays.equals(iaWitness, ft.getArgArray())); assertEquals(t, ft.getThrowable()); ft = MessageFormatter.arrayFormat("Val={}, {, Val={}", ia); assertEquals("Val=1, {, Val=2", ft.getMessage()); assertTrue(Arrays.equals(iaWitness, ft.getArgArray())); assertEquals(t, ft.getThrowable()); ft = MessageFormatter.arrayFormat("Val={}, \\{, Val={}", ia); assertEquals("Val=1, \\{, Val=2", ft.getMessage()); assertTrue(Arrays.equals(iaWitness, ft.getArgArray())); assertEquals(t, ft.getThrowable()); ft = MessageFormatter.arrayFormat("Val1={}, Val2={", ia); assertEquals("Val1=1, Val2={", ft.getMessage()); assertTrue(Arrays.equals(iaWitness, ft.getArgArray())); assertEquals(t, ft.getThrowable()); ft = MessageFormatter.arrayFormat("Value {} is smaller than {} and {}.", ia); assertEquals("Value 1 is smaller than 2 and 3.", ft.getMessage()); assertTrue(Arrays.equals(iaWitness, ft.getArgArray())); assertEquals(t, ft.getThrowable()); ft = MessageFormatter.arrayFormat("{}{}{}{}", ia); assertEquals("123{}", ft.getMessage()); assertTrue(Arrays.equals(iaWitness, ft.getArgArray())); assertEquals(t, ft.getThrowable()); ft = MessageFormatter.arrayFormat("1={}", new Object[] { i1 }, t); assertEquals("1=1", ft.getMessage()); assertTrue(Arrays.equals(new Object[] { i1 }, ft.getArgArray())); assertEquals(t, ft.getThrowable()); }
final public static FormattingTuple arrayFormat(final String messagePattern, final Object[] argArray) { Throwable throwableCandidate = MessageFormatter.getThrowableCandidate(argArray); Object[] args = argArray; if (throwableCandidate != null) { args = MessageFormatter.trimmedCopy(argArray); } return arrayFormat(messagePattern, args, throwableCandidate); }
MessageFormatter { final public static FormattingTuple arrayFormat(final String messagePattern, final Object[] argArray) { Throwable throwableCandidate = MessageFormatter.getThrowableCandidate(argArray); Object[] args = argArray; if (throwableCandidate != null) { args = MessageFormatter.trimmedCopy(argArray); } return arrayFormat(messagePattern, args, throwableCandidate); } }
MessageFormatter { final public static FormattingTuple arrayFormat(final String messagePattern, final Object[] argArray) { Throwable throwableCandidate = MessageFormatter.getThrowableCandidate(argArray); Object[] args = argArray; if (throwableCandidate != null) { args = MessageFormatter.trimmedCopy(argArray); } return arrayFormat(messagePattern, args, throwableCandidate); }  }
MessageFormatter { final public static FormattingTuple arrayFormat(final String messagePattern, final Object[] argArray) { Throwable throwableCandidate = MessageFormatter.getThrowableCandidate(argArray); Object[] args = argArray; if (throwableCandidate != null) { args = MessageFormatter.trimmedCopy(argArray); } return arrayFormat(messagePattern, args, throwableCandidate); }  final static FormattingTuple format(String messagePattern, Object arg); final static FormattingTuple format(final String messagePattern, Object arg1, Object arg2); final static FormattingTuple arrayFormat(final String messagePattern, final Object[] argArray); final static String basicArrayFormat(final String messagePattern, final Object[] argArray); static String basicArrayFormat(NormalizedParameters np); final static FormattingTuple arrayFormat(final String messagePattern, final Object[] argArray, Throwable throwable); static Throwable getThrowableCandidate(final Object[] argArray); static Object[] trimmedCopy(final Object[] argArray); }
MessageFormatter { final public static FormattingTuple arrayFormat(final String messagePattern, final Object[] argArray) { Throwable throwableCandidate = MessageFormatter.getThrowableCandidate(argArray); Object[] args = argArray; if (throwableCandidate != null) { args = MessageFormatter.trimmedCopy(argArray); } return arrayFormat(messagePattern, args, throwableCandidate); }  final static FormattingTuple format(String messagePattern, Object arg); final static FormattingTuple format(final String messagePattern, Object arg1, Object arg2); final static FormattingTuple arrayFormat(final String messagePattern, final Object[] argArray); final static String basicArrayFormat(final String messagePattern, final Object[] argArray); static String basicArrayFormat(NormalizedParameters np); final static FormattingTuple arrayFormat(final String messagePattern, final Object[] argArray, Throwable throwable); static Throwable getThrowableCandidate(final Object[] argArray); static Object[] trimmedCopy(final Object[] argArray);  }