Fix FN when empty (with a configurable option) + some i18n
[jvcard.git] / src / be / nikiroo / jvcard / Data.java
index d6ba628d3353fa2f1b22d0f1440790a06c268631..ba5fde5df13a9d86381b965aa1487d702ff61be8 100644 (file)
@@ -71,25 +71,33 @@ public class Data extends BaseClass<TypeInfo> {
        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<TypeInfo> {
                        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;