TextTable { public static int realDataLen(Object data) { if (data == null) { return 0; } String dataString = data.toString(); int totalLength = dataString.length(); Matcher matcher = METADATA_PATTERN.matcher(dataString); while (matcher.find()) { String withMeta = matcher.group(1); String justData = matcher.group(2); int metaLegth = withMeta.length() - justData.length(); totalLength -= metaLegth; } return totalLength; }  static String makeTable(String[] columnNames, int sortIndex, Object[][] data, boolean rowNumbering); static int realDataLen(Object data);  }
@Test public void testRealDataLen() { String data = null; int len = TextTable.realDataLen(data); Assert.assertEquals(0, len); data = ""; len = TextTable.realDataLen(data); Assert.assertEquals(0, len); data = " "; len = TextTable.realDataLen(data); Assert.assertEquals(1, len); String name = "hopsworks1"; String website = "Karamel Website"; data = "<a kref='shellconnect hopsworks1'>" + name + "</a>"; len = TextTable.realDataLen(data); Assert.assertEquals(name.length(), len); data = "baba <a kref='shellconnect hopsworks1'>" + name + "</a> mkmk<<>>"; len = TextTable.realDataLen(data); Assert.assertEquals(("baba ".length() + name.length() + " mkmk<<>>".length()), len); data = "baba <a kref='shellconnect hopsworks1'>" + name + "</a> mkmk<<>> <a href='http: website + "</a>"; len = TextTable.realDataLen(data); Assert.assertEquals("baba ".length() + name.length() + " mkmk<<>> ".length() + website.length(), len); }