+ /**
+ * 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. The parameters allows you to:
+ * <ul>
+ * <li>@x: show only a present/not present info</li>
+ * <li>@n: limit the size to a fixed value 'n'</li>
+ * <li>@+: expand the size of this field as much as possible</li>
+ * </ul>
+ *
+ * Example: "N@10|FN@20|NICK@+|PHOTO@x"
+ *
+ * @param format
+ * the format to use
+ * @param separator
+ * the separator {@link String} to use between fields
+ * @param padding
+ * the {@link String} to use for left and right padding
+ * @param width
+ * a fixed width or -1 for "as long as needed"
+ *
+ * @return the {@link String} representation
+ */
+ public String[] toStringArray(String format, String separator,
+ String padding, int width) {
+ if (width > -1) {
+ int numOfFields = format.split("\\|").length;
+ if (separator != null)
+ width -= (numOfFields - 1) * separator.length();
+ if (padding != null)
+ width -= (numOfFields) * (2 * padding.length());
+
+ if (width < 0)
+ width = 0;