X-Git-Url: http://git.nikiroo.be/?p=jvcard.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2FData.java;h=377c41e29edbbbc8d97d73d2d27c79390752944f;hp=f2bb4080f6d770776e1824e0cf7cfd7495c20433;hb=176a83279a5aafb7e44cc7c34bf78f0bc35225fe;hpb=adf9c44949504512002cff293641225b31ec568a diff --git a/src/be/nikiroo/jvcard/Data.java b/src/be/nikiroo/jvcard/Data.java index f2bb408..377c41e 100644 --- a/src/be/nikiroo/jvcard/Data.java +++ b/src/be/nikiroo/jvcard/Data.java @@ -85,6 +85,49 @@ public class Data { return types.get(index); } + /** + * Add a new {@link TypeInfo} in this {@link Data}. + * + * @param type + * the new type + */ + public void add(TypeInfo type) { + type.setParent(this); + type.setDirty(); + types.add(type); + } + + /** + * Remove the given {@link TypeInfo} from its this {@link Data} if it is in. + * + * @return TRUE in case of success + */ + public boolean remove(TypeInfo type) { + if (types.remove(type)) { + setDirty(); + } + + return false; + } + + /** + * Change the {@link TypeInfo}s of this {@link Data}. + * + * @param types + * the new types + */ + @Deprecated + public void setTypes(List types) { + // TODO: check if this method is required + this.types.clear(); + for (TypeInfo type : types) { + this.types.add(type); + type.setParent(this); + } + + setDirty(); + } + /** * Return the name of this {@link Data} * @@ -126,6 +169,20 @@ public class Data { return group; } + /** + * Change the group of this {@link Data} + * + * @param group + * the new group + */ + public void setGroup(String group) { + if ((group == null && this.group != null) + || (group != null && !group.equals(this.group))) { + this.group = group; + setDirty(); + } + } + /** * Return the bkey number of this {@link Data} or -1 if it is not binary. * @@ -164,6 +221,19 @@ public class Data { return b64 >= 0; } + /** + * Delete this {@link Contact} from its parent {@link Card} if any. + * + * @return TRUE in case of success + */ + public boolean delete() { + if (parent != null) { + return parent.remove(this); + } + + return false; + } + /** * Check if this {@link Data} has unsaved changes. *