@Test public void testGetTxtLine() { String line = TextUtil.getTxtLine(new X(), ";", null, true); assertEquals(clean("LstInts=[...];LstStr=[...];X= 5;Y=6;Class=X"), clean(line)); line = TextUtil.getTxtLine(new X(), ";", null, false); assertEquals(clean(" [...]; [...]; 5;6; X"), clean(line)); line = TextUtil.getTxtLine(new ExtendsXNoAnno(), "|", null, true); assertEquals(clean("Prop=true|LstInts=[...]|LstStr=[...]|X= 5|Y=6|Class=ExtendsXNoAnno"), clean(line)); line = TextUtil.getTxtLine(new ExtendsXNoAnno(), ";", null, false); assertEquals(clean("true; [...]; [...]; 5;6;ExtendsXNoAnno"), clean(line)); line = TextUtil.getTxtLine(new ExtendsXAnno(), "|", null, true); assertEquals(clean("Prop=true|Y=6"), clean(line)); line = TextUtil.getTxtLine(new ExtendsXAnno(), ";", null, false); assertEquals(clean("true;6"), clean(line)); line = TextUtil.getTxtLine(new ExtendsXAnno(), ";", new String[] { "X", "Y" }, false); assertEquals(clean("5;6"), clean(line)); line = TextUtil.getTxtLine(new ExtendsXAnno(), ";", new String[] { "Y", "X" }, false); assertEquals(clean("6;5"), clean(line)); line = TextUtil.getTxtLine(new ExtendsXNoAnno(), ";", new String[] { "X" }, false); assertEquals(clean("5"), clean(line)); }
public static String getTxtLine(final List<?> objects, final List<String> headers, final String delimeter, final boolean includeFieldNames) { StringBuffer result = new StringBuffer(); for (int i = 0; i < objects.size(); i++) { String txt = toString(objects.get(i)); String propName = headers.get(i); if (includeFieldNames) { result.append(propName + "=" + txt); } else { if (propName.length() > txt.length()) { txt = String.format("%" + propName.length() + "s", txt); } result.append(txt); } result.append(i < objects.size() - 1 ? delimeter : ""); } return result.toString(); }
TextUtil { public static String getTxtLine(final List<?> objects, final List<String> headers, final String delimeter, final boolean includeFieldNames) { StringBuffer result = new StringBuffer(); for (int i = 0; i < objects.size(); i++) { String txt = toString(objects.get(i)); String propName = headers.get(i); if (includeFieldNames) { result.append(propName + "=" + txt); } else { if (propName.length() > txt.length()) { txt = String.format("%" + propName.length() + "s", txt); } result.append(txt); } result.append(i < objects.size() - 1 ? delimeter : ""); } return result.toString(); } }
TextUtil { public static String getTxtLine(final List<?> objects, final List<String> headers, final String delimeter, final boolean includeFieldNames) { StringBuffer result = new StringBuffer(); for (int i = 0; i < objects.size(); i++) { String txt = toString(objects.get(i)); String propName = headers.get(i); if (includeFieldNames) { result.append(propName + "=" + txt); } else { if (propName.length() > txt.length()) { txt = String.format("%" + propName.length() + "s", txt); } result.append(txt); } result.append(i < objects.size() - 1 ? delimeter : ""); } return result.toString(); }  }
TextUtil { public static String getTxtLine(final List<?> objects, final List<String> headers, final String delimeter, final boolean includeFieldNames) { StringBuffer result = new StringBuffer(); for (int i = 0; i < objects.size(); i++) { String txt = toString(objects.get(i)); String propName = headers.get(i); if (includeFieldNames) { result.append(propName + "=" + txt); } else { if (propName.length() > txt.length()) { txt = String.format("%" + propName.length() + "s", txt); } result.append(txt); } result.append(i < objects.size() - 1 ? delimeter : ""); } return result.toString(); }  static String getCaptionLine(final List<String> headers, final List<? extends Class<?>> headerClasses,
            final String delim); static String getTxtLine(final List<?> objects, final List<String> headers, final String delimeter,
            final boolean includeFieldNames); static String getTxtLine(final Object obj); static String getTxtLine(final Object obj, final String delimeter); static String getTxtLine(final Object obj, final String[] properties); static String getTxtLine(final Object obj, final String delimeter, final String[] properties); static String getTxtLine(final Object obj, final String delimeter, final String[] properties,
            final boolean includeFieldNames); @SuppressWarnings({ "rawtypes", "unchecked" }) static String getTxtLine(final F obj, final String delimeter, final String[] properties,
            final boolean includeFieldNames, final LinkedHashMap<String, Function<? extends F, String>> virtualProps); static String getTxtLine(final F obj, final String[] properties,
            final LinkedHashMap<String, Function<? extends F, String>> virtualProps); static String getCaptionLine(final Class<?> clazz); static String getCaptionLine(final Class<?> clazz, final String delimeter); static String getCaptionLine(final Class<?> clazz, final String[] properties); static String getCaptionLine(final Class<?> clazz, final String delimeter, final String[] properties); static String getCaptionLine(final Class<?> clazz, final String delimeter, final String[] properties,
            final String[] virtualProps); static String getCaptionLine(final Class<?> clazz, final String[] properties, final String[] virtualProps); static String getCaptionLine(final Class<?> clazz, final String[] properties, Iterable<String> virtualProps); static String toString(final Object obj); static DateFormat getDateFormat(); static DateFormat getTimeFormat(); static String getReadableTime(double time); }
TextUtil { public static String getTxtLine(final List<?> objects, final List<String> headers, final String delimeter, final boolean includeFieldNames) { StringBuffer result = new StringBuffer(); for (int i = 0; i < objects.size(); i++) { String txt = toString(objects.get(i)); String propName = headers.get(i); if (includeFieldNames) { result.append(propName + "=" + txt); } else { if (propName.length() > txt.length()) { txt = String.format("%" + propName.length() + "s", txt); } result.append(txt); } result.append(i < objects.size() - 1 ? delimeter : ""); } return result.toString(); }  static String getCaptionLine(final List<String> headers, final List<? extends Class<?>> headerClasses,
            final String delim); static String getTxtLine(final List<?> objects, final List<String> headers, final String delimeter,
            final boolean includeFieldNames); static String getTxtLine(final Object obj); static String getTxtLine(final Object obj, final String delimeter); static String getTxtLine(final Object obj, final String[] properties); static String getTxtLine(final Object obj, final String delimeter, final String[] properties); static String getTxtLine(final Object obj, final String delimeter, final String[] properties,
            final boolean includeFieldNames); @SuppressWarnings({ "rawtypes", "unchecked" }) static String getTxtLine(final F obj, final String delimeter, final String[] properties,
            final boolean includeFieldNames, final LinkedHashMap<String, Function<? extends F, String>> virtualProps); static String getTxtLine(final F obj, final String[] properties,
            final LinkedHashMap<String, Function<? extends F, String>> virtualProps); static String getCaptionLine(final Class<?> clazz); static String getCaptionLine(final Class<?> clazz, final String delimeter); static String getCaptionLine(final Class<?> clazz, final String[] properties); static String getCaptionLine(final Class<?> clazz, final String delimeter, final String[] properties); static String getCaptionLine(final Class<?> clazz, final String delimeter, final String[] properties,
            final String[] virtualProps); static String getCaptionLine(final Class<?> clazz, final String[] properties, final String[] virtualProps); static String getCaptionLine(final Class<?> clazz, final String[] properties, Iterable<String> virtualProps); static String toString(final Object obj); static DateFormat getDateFormat(); static DateFormat getTimeFormat(); static String getReadableTime(double time); static final DecimalFormat DEC_FORMAT; static final int SIZE_OF_DBL_STRINGS; static final int SIZE_OF_INT_STRINGS; static final int SIZE_OF_STRINGS; static final String NEW_LINE; static final String DEFAULT_DELIM; }