X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Fparsers%2FVcard21Parser.java;h=5388783a48cda3bd75ddfb7d199d8ceaa92fcf89;hb=aecb3399b756d2ba04223bc6f553999fce73f9fb;hp=7d0f5e86beb98e17efb7cef1c4520fef3faa798b;hpb=0b6140e4a200c4952c9dc003d8389f375191564e;p=jvcard.git diff --git a/src/be/nikiroo/jvcard/parsers/Vcard21Parser.java b/src/be/nikiroo/jvcard/parsers/Vcard21Parser.java index 7d0f5e8..5388783 100644 --- a/src/be/nikiroo/jvcard/parsers/Vcard21Parser.java +++ b/src/be/nikiroo/jvcard/parsers/Vcard21Parser.java @@ -201,13 +201,13 @@ public class Vcard21Parser { dataBuilder.append(type.getName()); if (type.getValue() != null && !type.getValue().trim().equals("")) { dataBuilder.append('='); - dataBuilder.append(type.getValue()); + dataBuilder.append(type.getRawValue()); } } dataBuilder.append(':'); // TODO: bkey! - dataBuilder.append(data.getValue()); + dataBuilder.append(data.getRawValue()); // RFC says: Content lines SHOULD be folded to a maximum width of 75 // octets -> since it is SHOULD, we will just cut it as 74/75 chars @@ -239,6 +239,31 @@ public class Vcard21Parser { return lines; } + /** + * Clone the given {@link Card} by exporting then importing it again in VCF. + * + * @param c + * the {@link Card} to clone + * + * @return the clone {@link Contact} + */ + public static Card clone(Card c) { + return new Card(parseContact(toStrings(c))); + } + + /** + * Clone the given {@link Contact} by exporting then importing it again in + * VCF. + * + * @param c + * the {@link Contact} to clone + * + * @return the clone {@link Contact} + */ + public static Contact clone(Contact c) { + return parseContact(toStrings(c, -1)).get(0); + } + /** * Check if the given line is a continuation line or not. *