X-Git-Url: http://git.nikiroo.be/?p=jvcard.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Fparsers%2FParser.java;h=040cd3e113ab9862b15ace9c3967bfca4610878b;hp=ceb35dccca75de055917b4050b5df3f912110fb3;hb=59597d59aa262e31c2e1b7f66b4cb299f88ebd1b;hpb=e3fe983485916e0f3dbae73394f9dd8271623639 diff --git a/src/be/nikiroo/jvcard/parsers/Parser.java b/src/be/nikiroo/jvcard/parsers/Parser.java index ceb35dc..040cd3e 100644 --- a/src/be/nikiroo/jvcard/parsers/Parser.java +++ b/src/be/nikiroo/jvcard/parsers/Parser.java @@ -73,24 +73,27 @@ public class Parser { } /** - * Return a {@link String} representation of the given {@link Card}, line by - * line. + * Write the given {@link Card} in the {@link Appendable}. * + * @param writer + * the {@link Appendable} * @param card - * the card to convert - * + * the {@link Card} to write * @param format - * the output {@link Format} to use + * the {@link Format} to export to * - * @return the {@link String} representation + * @throws IOException + * in case of IO error */ - public static List toStrings(Card card, Format format) { + public static void write(Appendable writer, Format format, Card card) + throws IOException { switch (format) { case VCard21: - return Vcard21Parser.toStrings(card); + Vcard21Parser.write(writer, card); + break; case Abook: - return AbookParser.toStrings(card); - + AbookParser.write(writer, card); + break; default: throw new InvalidParameterException("Unknown format: " + format.toString()); @@ -98,29 +101,30 @@ public class Parser { } /** - * Return a {@link String} representation of the given {@link Card}, line by - * line. - * - * @param card - * the card to convert + * Write the given {@link Contact} in the {@link Appendable}. * + * @param writer + * the {@link Appendable} + * @param contact + * the {@link Contact} to write * @param startingBKey * the starting BKey number (all the other will follow) or -1 for * no BKey - * * @param format - * the output {@link Format} to use + * the {@link Format} to export to * - * @return the {@link String} representation + * @throws IOException + * in case of IO error */ - public static List toStrings(Contact contact, Format format, - int startingBKey) { + public static void write(Appendable writer, Contact contact, Format format, + int startingBKey) throws IOException { switch (format) { case VCard21: - return Vcard21Parser.toStrings(contact, startingBKey); + Vcard21Parser.write(writer, contact, startingBKey); + break; case Abook: - return AbookParser.toStrings(contact, startingBKey); - + AbookParser.write(writer, contact, startingBKey); + break; default: throw new InvalidParameterException("Unknown format: " + format.toString());