X-Git-Url: https://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2FData.java;h=3f62b7e8f0f6158aff806a4baa06ff2b59ef8dc2;hb=bcb54330afff6a443ab43ee3d38cc7f863c701b7;hp=993533263eaf6d6f2ab09a2d05339b82f0a4af99;hpb=0b0b2b0ff1f5e21f7b0feb955b4b54855fb3d508;p=jvcard.git diff --git a/src/be/nikiroo/jvcard/Data.java b/src/be/nikiroo/jvcard/Data.java index 9935332..3f62b7e 100644 --- a/src/be/nikiroo/jvcard/Data.java +++ b/src/be/nikiroo/jvcard/Data.java @@ -45,6 +45,14 @@ public class Data { return value; } + public void setValue(String value) { + if ((value == null && this.value != null) + || (value != null && !value.equals(this.value))) { + this.value = value; + setDirty(); + } + } + public String getGroup() { return group; } @@ -72,7 +80,29 @@ public class Data { return dirty; } - public void setParent(Contact parent) { + /** + * Notify that this element has unsaved changes, and notify its parent of + * the same if any. + */ + protected void setDirty() { + this.dirty = true; + if (this.parent != null) + this.parent.setDirty(); + } + + /** + * Notify this element and all its descendants that it is in pristine + * state (as opposed to dirty). + */ + void setPristine() { + dirty = false; + for (TypeInfo type : types) { + // TODO ? + } + } + + void setParent(Contact parent) { this.parent = parent; } + }