Commit | Line | Data |
---|---|---|
a3b510ab NR |
1 | package be.nikiroo.jvcard; |
2 | ||
3 | public class TypeInfo { | |
4 | private String name; | |
5 | private String value; | |
78e4af97 NR |
6 | private Data parent; |
7 | private boolean dirty; | |
a3b510ab NR |
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 | } | |
78e4af97 NR |
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 | } | |
a3b510ab | 58 | } |