+ for (String str : toStringArray(format, width)) {
+ builder.append(str);
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * Return a {@link String} representation of this contact formated
+ * accordingly to the given format, part by part.
+ *
+ * The format is basically a list of field names separated by a pipe and
+ * optionally parametrised. See {@link Contact#toString} for more
+ * information about the format.
+ *
+ * @param format
+ * the format to use
+ * @param width
+ * a fixed width or -1 for "as long as needed"
+ *
+ * @return the {@link String} representation
+ */
+ public String[] toStringArray(String format, int width) {
+ List<String> str = new LinkedList<String>();
+
+ String[] formatFields = format.split("\\|");
+ String[] values = new String[formatFields.length];
+ Boolean[] expandedFields = new Boolean[formatFields.length];
+ Boolean[] fixedsizeFields = new Boolean[formatFields.length];
+ int numOfFieldsToExpand = 0;
+ int totalSize = 0;
+
+ if (width == 0) {
+ return str.toArray(new String[] {});
+ }
+