1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package nl.hippo.portal.cms;
17
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Map;
21
22 public class CMSMetaDataItemImpl implements CMSMetaDataItem {
23
24 private final String id;
25 private final Map attributes;
26 private final String value;
27 private List children = new ArrayList();
28 private CMSMetaDataItem parent;
29 private int nestingLevel;
30
31 public CMSMetaDataItemImpl(String id, String value, Map attributes) {
32 this.id = id;
33 this.attributes = attributes;
34 this.value = value;
35 nestingLevel = 0;
36 }
37
38 public String getAttribute(String key) {
39 return (String) attributes.get(key);
40 }
41
42 public Map getAttributes() {
43 return attributes;
44 }
45
46 public List getChildren() {
47 return children;
48 }
49
50 public void addChild(CMSMetaDataItemImpl child) {
51 children.add(child);
52 child.setNestingLevel(nestingLevel + 1);
53 child.setParent(this);
54 }
55
56 public String getId() {
57 return id;
58 }
59
60 public CMSMetaDataItem getParent() {
61 return parent;
62 }
63
64 public void setParent(CMSMetaDataItem parent) {
65 this.parent = parent;
66 }
67
68 public String getValue() {
69 return value;
70 }
71
72 public boolean hasChildren() {
73 return !children.isEmpty();
74 }
75
76 public String toString() {
77 return "id="+id + ", value="+value+", nrOfChildren="+children.size();
78 }
79
80 public int getNestingLevel() {
81 return nestingLevel;
82 }
83
84 private void setNestingLevel(int nestingLevel) {
85 this.nestingLevel = nestingLevel;
86 }
87
88 }