* @throws IOException
* in case of IO error
*/
- public static List<Contact> parse(File file, Format format)
+ public static List<Contact> parseContact(File file, Format format)
throws IOException {
List<String> lines = null;
if (lines == null)
return new LinkedList<Contact>();
- return parse(lines, format);
+ return parseContact(lines, format);
}
/**
*
* @return the list of elements
*/
- public static List<Contact> parse(List<String> lines, Format format) {
+ public static List<Contact> parseContact(List<String> 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: "
}
}
- // -1 = no bkeys
- public static String toString(Card card, Format format) {
+ /**
+ * Write the given {@link Card} in the {@link Appendable}.
+ *
+ * @param writer
+ * the {@link Appendable}
+ * @param card
+ * the {@link Card} to write
+ * @param format
+ * the {@link Format} to export to
+ *
+ * @throws IOException
+ * in case of IO error
+ */
+ public static void write(Appendable writer, Format format, Card card)
+ throws IOException {
switch (format) {
case VCard21:
- return Vcard21Parser.toString(card);
+ Vcard21Parser.write(writer, card);
+ break;
case Abook:
- return AbookParser.toString(card);
-
+ AbookParser.write(writer, card);
+ break;
default:
throw new InvalidParameterException("Unknown format: "
+ format.toString());
}
}
- // -1 = no bkeys
- public static String toString(Contact contact, Format format,
- int startingBKey) {
+ /**
+ * 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 {@link Format} to export to
+ *
+ * @throws IOException
+ * in case of IO error
+ */
+ public static void write(Appendable writer, Contact contact, Format format,
+ int startingBKey) throws IOException {
switch (format) {
case VCard21:
- return Vcard21Parser.toString(contact, startingBKey);
+ Vcard21Parser.write(writer, contact, startingBKey);
+ break;
case Abook:
- return AbookParser.toString(contact, startingBKey);
-
+ AbookParser.write(writer, contact, startingBKey);
+ break;
default:
throw new InvalidParameterException("Unknown format: "
+ format.toString());