X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Fparsers%2FParser.java;h=040cd3e113ab9862b15ace9c3967bfca4610878b;hb=ed91f27a4f628ec59b0e85cdbb0319287c503f9d;hp=1fa7c5749805746d58e41f9fae52e575e2cb529d;hpb=cf77cb3542f2aefbebdb9aa00b358dbeb4489a73;p=jvcard.git diff --git a/src/be/nikiroo/jvcard/parsers/Parser.java b/src/be/nikiroo/jvcard/parsers/Parser.java index 1fa7c57..040cd3e 100644 --- a/src/be/nikiroo/jvcard/parsers/Parser.java +++ b/src/be/nikiroo/jvcard/parsers/Parser.java @@ -28,7 +28,7 @@ public class Parser { * @throws IOException * in case of IO error */ - public static List parse(File file, Format format) + public static List parseContact(File file, Format format) throws IOException { List lines = null; @@ -46,7 +46,7 @@ public class Parser { if (lines == null) return new LinkedList(); - return parse(lines, format); + return parseContact(lines, format); } /** @@ -59,12 +59,12 @@ public class Parser { * * @return the list of elements */ - public static List parse(List lines, Format format) { + public static List parseContact(List lines, Format format) { switch (format) { case VCard21: - return Vcard21Parser.parse(lines); + return Vcard21Parser.parseContact(lines); case Abook: - return AbookParser.parse(lines); + return AbookParser.parseContact(lines); default: throw new InvalidParameterException("Unknown format: " @@ -73,28 +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 - * - * @param startingBKey - * the starting BKey number (all the other will follow) or -1 for - * no BKey - * + * 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()); @@ -102,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());