AbstractMetaDataNode.java
2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.cq.mcm.campaign.profile.impl;
import com.adobe.cq.mcm.campaign.profile.MetaDataNode;
import com.adobe.cq.mcm.campaign.profile.Options;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class AbstractMetaDataNode
implements MetaDataNode {
private final String id;
private final String path;
private final String label;
private final String type;
private final List<MetaDataNode> children;
private final Map<String, MetaDataNode> childById;
private final Options options;
protected AbstractMetaDataNode(String id, String parentPath, String label, String type, Options options) {
this.id = id;
this.path = parentPath != null ? parentPath + "/" + id : "";
this.label = label;
this.type = type != null && type.length() > 0 ? type : null;
this.children = new ArrayList<MetaDataNode>(4);
this.childById = new HashMap<String, MetaDataNode>(4);
this.options = options;
}
@Override
public String getId() {
return this.id;
}
@Override
public String getPath() {
return this.path;
}
@Override
public String getLabel() {
return this.label;
}
@Override
public String getType() {
return this.type;
}
@Override
public MetaDataNode add(MetaDataNode child) {
this.children.add(child);
this.childById.put(child.getId(), child);
return child;
}
@Override
public Iterator<MetaDataNode> getChildren() {
return this.children.iterator();
}
@Override
public MetaDataNode getChildByPath(String relPath) {
int nextSegPos = relPath.indexOf("/");
if (nextSegPos >= 0) {
String childSeg = relPath.substring(0, nextSegPos);
MetaDataNode segment = this.childById.get(childSeg);
if (segment == null) {
return null;
}
String childPath = relPath.substring(nextSegPos + 1);
return segment.getChildByPath(childPath);
}
return this.childById.get(relPath);
}
@Override
public boolean hasOptions() {
return this.options != null;
}
@Override
public Options getOptions() {
return this.options;
}
public String toString() {
StringBuilder dump = new StringBuilder();
dump.append(this.path).append("->").append(this.label).append(" (").append(this.type).append("); ");
for (MetaDataNode node : this.children) {
dump.append(node.toString());
}
return dump.toString();
}
}