X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2FBaseClass.java;h=9533321b2f0b0673a5a00d236c3c8cff008a2540;hb=f06c81000632cfb5f525ca458f719338f55f9f66;hp=1dd76442324ca845d2f603e5dd04c532bd7bdd32;hpb=5ad0e17e7fea1c602cb2638a006424af9c7e33e8;p=jvcard.git diff --git a/src/be/nikiroo/jvcard/BaseClass.java b/src/be/nikiroo/jvcard/BaseClass.java index 1dd7644..9533321 100644 --- a/src/be/nikiroo/jvcard/BaseClass.java +++ b/src/be/nikiroo/jvcard/BaseClass.java @@ -10,7 +10,7 @@ import java.util.LinkedList; import java.util.List; import java.util.ListIterator; -import be.nikiroo.jvcard.resources.StringUtils; +import be.nikiroo.utils.StringUtils; /** * This class is basically a List with a parent and a "dirty" state check. It @@ -30,7 +30,7 @@ import be.nikiroo.jvcard.resources.StringUtils; *

* * @author niki - * + * * @param * the type of the child elements */ @@ -275,7 +275,7 @@ public abstract class BaseClass> implements List { public String getContentState(boolean self) { StringBuilder builder = new StringBuilder(); buildContentStateRaw(builder, self); - return StringUtils.getHash(builder.toString()); + return StringUtils.getMd5Hash(builder.toString()); } /** @@ -433,6 +433,38 @@ public abstract class BaseClass> implements List { } } + /** + * Escape the given value to VCF standard. + * + * @param value + * the value to escape + * + * @return the escaped value + */ + protected String escape(String value) { + if (value == null) + return null; + + return value.replaceAll(",", "\\\\,").replaceAll(";", "\\\\;") + .replaceAll("\n", "\\\\n"); + } + + /** + * Unescape the given value from the VCF standard. + * + * @param value + * the value to unescape + * + * @return the unescaped value + */ + protected String unescape(String value) { + if (value == null) + return null; + + return value.replaceAll("\\\\,", ",").replaceAll("\\\\;", ";") + .replaceAll("\\\\n", "\n"); + } + /** * Each element that leaves the parent will pass trough here. *