@Test public void testTruncate() { String expected = "abc"; assertTrue(AbstractAFPObject.truncate(expected, 4) == expected); assertTrue(AbstractAFPObject.truncate(expected, 3) == expected); assertEquals(AbstractAFPObject.truncate(expected + "d", 3), expected); assertEquals(AbstractAFPObject.truncate(expected, 0), ""); try { assertTrue(AbstractAFPObject.truncate(null, 4) == null); fail(); } catch (NullPointerException e) { } }
protected static String truncate(String str, int maxLength) { if (str.length() > maxLength) { str = str.substring(0, maxLength); LOG.warn("truncated character string '" + str + "', longer than " + maxLength + " chars"); } return str; }
AbstractAFPObject implements Streamable { protected static String truncate(String str, int maxLength) { if (str.length() > maxLength) { str = str.substring(0, maxLength); LOG.warn("truncated character string '" + str + "', longer than " + maxLength + " chars"); } return str; } }
AbstractAFPObject implements Streamable { protected static String truncate(String str, int maxLength) { if (str.length() > maxLength) { str = str.substring(0, maxLength); LOG.warn("truncated character string '" + str + "', longer than " + maxLength + " chars"); } return str; }  }
AbstractAFPObject implements Streamable { protected static String truncate(String str, int maxLength) { if (str.length() > maxLength) { str = str.substring(0, maxLength); LOG.warn("truncated character string '" + str + "', longer than " + maxLength + " chars"); } return str; }   }
AbstractAFPObject implements Streamable { protected static String truncate(String str, int maxLength) { if (str.length() > maxLength) { str = str.substring(0, maxLength); LOG.warn("truncated character string '" + str + "', longer than " + maxLength + " chars"); } return str; }    }