X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Fparsers%2FAbookParser.java;h=344ae705401652905fe49563fa5fac4110be9f41;hb=cf77cb3542f2aefbebdb9aa00b358dbeb4489a73;hp=2fd0ca2f15a61e1e92833d4a373364b6c4ccde05;hpb=bcb54330afff6a443ab43ee3d38cc7f863c701b7;p=jvcard.git diff --git a/src/be/nikiroo/jvcard/parsers/AbookParser.java b/src/be/nikiroo/jvcard/parsers/AbookParser.java index 2fd0ca2..344ae70 100644 --- a/src/be/nikiroo/jvcard/parsers/AbookParser.java +++ b/src/be/nikiroo/jvcard/parsers/AbookParser.java @@ -1,5 +1,6 @@ package be.nikiroo.jvcard.parsers; +import java.util.Arrays; import java.util.LinkedList; import java.util.List; @@ -10,7 +11,7 @@ import be.nikiroo.jvcard.Data; public class AbookParser { public static List parse(List lines) { List contacts = new LinkedList(); - + for (String line : lines) { List content = new LinkedList(); @@ -33,8 +34,24 @@ public class AbookParser { return contacts; } - // -1 = no bkeys - public static String toString(Contact contact, int startingBKey) { + /** + * Return a {@link String} representation of the given {@link Card}, line by + * line. + * + *

+ * Note that the BKey is actually not used in Pine mode. + *

+ * + * @param card + * the card to convert + * + * @param startingBKey + * the starting BKey number (all the other will follow) or -1 for + * no BKey + * + * @return the {@link String} representation + */ + public static List toStrings(Contact contact, int startingBKey) { // BKey is not used in pine mode StringBuilder builder = new StringBuilder(); @@ -83,17 +100,26 @@ public class AbookParser { // note: save as pine means normal LN, nor CRLN builder.append('\n'); - - return builder.toString(); - } - public static String toString(Card card) { - StringBuilder builder = new StringBuilder(); + return Arrays.asList(new String[] { builder.toString() }); + } - for (Contact contact : card.getContactsList()) { - builder.append(toString(contact, -1)); + /** + * Return a {@link String} representation of the given {@link Card}, line by + * line. + * + * @param card + * the card to convert + * + * @return the {@link String} representation + */ + public static List toStrings(Card card) { + List lines = new LinkedList(); + + for (int index = 0; index < card.size(); index++) { + lines.addAll(toStrings(card.get(index), -1)); } - return builder.toString(); + return lines; } }