X-Git-Url: http://git.nikiroo.be/?p=jvcard.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2FData.java;h=ba5fde5df13a9d86381b965aa1487d702ff61be8;hp=d6ba628d3353fa2f1b22d0f1440790a06c268631;hb=30a4aa17f2141ad80a23447ee2e6303f6c9ef995;hpb=f29274a79cd091262b65411ce81127b9de47f9b6 diff --git a/src/be/nikiroo/jvcard/Data.java b/src/be/nikiroo/jvcard/Data.java index d6ba628..ba5fde5 100644 --- a/src/be/nikiroo/jvcard/Data.java +++ b/src/be/nikiroo/jvcard/Data.java @@ -71,25 +71,33 @@ public class Data extends BaseClass { public String getValue() { return unescape(value); } - + + /** + * Change the value of this {@link Data} + * + * @param value + * the new value + */ + public void setValue(String value) { + setRawValue(escape(value)); + } + /** - * Return the RAW value of this {@link Data} + * Return the raw value of this {@link Data} * - * @return the RAW value + * @return the raw value */ public String getRawValue() { return value; } /** - * Change the value of this {@link Data} + * Change the raw value of this {@link Data} * * @param value - * the new value + * the new raw value */ - public void setValue(String value) { - value = escape(value); - + public void setRawValue(String value) { if ((value == null && this.value != null) || (value != null && !value.equals(this.value))) { this.value = value; @@ -232,11 +240,13 @@ public class Data extends BaseClass { for (int i = 0; i < value.length(); i++) { if (value.charAt(i) == sep && (i == 0 || value.charAt(i - 1) != '\\')) { - rep.add(value.substring(last, i - last)); + rep.add(value.substring(last, i)); + last = i + 1; } } - rep.add(value.substring(last)); + if (last < value.length()) + rep.add(value.substring(last)); } return rep;