26314fa48a016603a9b3d9066a8d6d59f13a2c90
[jvcard.git] / src / be / nikiroo / jvcard / TypeInfo.java
1 package be.nikiroo.jvcard;
2
3 public class TypeInfo {
4 private String name;
5 private String value;
6 private Data parent;
7 private boolean dirty;
8
9 public TypeInfo(String name, String value) {
10 this.name = name;
11 this.value = value;
12 }
13
14 public String getName() {
15 return name;
16 }
17
18 public String getValue() {
19 return value;
20 }
21
22 /**
23 * Check if this {@link TypeInfo} has unsaved changes.
24 *
25 * @return TRUE if it has
26 */
27 public boolean isDirty() {
28 return dirty;
29 }
30
31 /**
32 * Notify that this element has unsaved changes, and notify its parent of
33 * the same if any.
34 */
35 protected void setDirty() {
36 this.dirty = true;
37 if (this.parent != null)
38 this.parent.setDirty();
39 }
40
41 /**
42 * Notify this element <i>and all its descendants</i> that it is in pristine
43 * state (as opposed to dirty).
44 */
45 void setPristine() {
46 dirty = false;
47 }
48
49 /**
50 * Set the parent of this {@link TypeInfo}.
51 *
52 * @param parent
53 * the new parent
54 */
55 void setParent(Data parent) {
56 this.parent = parent;
57 }
58 }