1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
package nl.toolforge.karma.core.manifest; |
20 |
|
|
21 |
|
import nl.toolforge.karma.core.module.ModuleDigester; |
22 |
|
|
23 |
|
import java.util.ArrayList; |
24 |
|
import java.util.Hashtable; |
25 |
|
import java.util.List; |
26 |
|
import java.util.Map; |
27 |
|
import java.util.regex.PatternSyntaxException; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
361 |
public final class ManifestStructure { |
37 |
361 |
|
38 |
494 |
private String name = null; |
39 |
133 |
private String version = null; |
40 |
494 |
private String type = null; |
41 |
|
|
42 |
494 |
private String description = null; |
43 |
361 |
|
44 |
133 |
private Map childs = null; |
45 |
494 |
private List modules = null; |
46 |
361 |
|
47 |
494 |
public ManifestStructure() { |
48 |
494 |
childs = new Hashtable(); |
49 |
133 |
modules = new ArrayList(); |
50 |
133 |
} |
51 |
228 |
|
52 |
|
public Map getChilds() { |
53 |
84 |
return childs; |
54 |
|
} |
55 |
114 |
|
56 |
|
public ManifestStructure getChild(String childName) { |
57 |
42 |
return (ManifestStructure) childs.get(childName); |
58 |
|
} |
59 |
152 |
|
60 |
19 |
public void addChild(ManifestStructure structure) throws ManifestException { |
61 |
56 |
if (childs.containsKey(structure.getName())) { |
62 |
140 |
throw new ManifestException(ManifestException.MANIFEST_NAME_RECURSION, class="keyword">new Object[] {structure.getName()}); |
63 |
133 |
} |
64 |
49 |
childs.put(structure.getName(), structure); |
65 |
49 |
} |
66 |
57 |
|
67 |
|
public List getModules() { |
68 |
21 |
return modules; |
69 |
|
} |
70 |
|
|
71 |
342 |
public void addModule(ModuleDigester digester) throws ManifestException { |
72 |
19 |
|
73 |
126 |
if (modules.contains(digester)) { |
74 |
330 |
throw new ManifestException(ManifestException.DUPLICATE_MODULE, class="keyword">new Object[] {digester.getName()}); |
75 |
323 |
} |
76 |
119 |
modules.add(digester); |
77 |
119 |
} |
78 |
475 |
|
79 |
|
public String getName() { |
80 |
182 |
return name; |
81 |
|
} |
82 |
|
|
83 |
361 |
public void setName(String name) { |
84 |
|
|
85 |
119 |
if (name.trim().startsWith(".")) { |
86 |
361 |
throw new IllegalArgumentException("A manifest name cannot start with a `.`."); |
87 |
361 |
} |
88 |
119 |
this.name = name; |
89 |
119 |
} |
90 |
|
|
91 |
|
public String getVersion() { |
92 |
0 |
return version; |
93 |
|
} |
94 |
|
|
95 |
209 |
public void setVersion(String version) { |
96 |
|
|
97 |
77 |
if (!version.matches("\\d{1}-\\d{1}")) { |
98 |
209 |
throw new PatternSyntaxException("A manifests' version attribute should look like '0-0'.", "\\d{1}-\\d{1}", -1); |
99 |
209 |
} |
100 |
77 |
this.version = version; |
101 |
77 |
} |
102 |
38 |
|
103 |
|
public String getType() { |
104 |
14 |
return type; |
105 |
|
} |
106 |
209 |
|
107 |
209 |
public void setType(String type) { |
108 |
77 |
this.type = type; |
109 |
77 |
} |
110 |
|
|
111 |
|
public String getDescription() { |
112 |
0 |
return description; |
113 |
|
} |
114 |
209 |
|
115 |
209 |
public void setDescription(String description) { |
116 |
77 |
this.description = description; |
117 |
77 |
} |
118 |
|
|
119 |
114 |
public void update(ManifestStructure child) { |
120 |
114 |
|
121 |
156 |
this.name = child.name; |
122 |
156 |
this.type = child.type; |
123 |
156 |
this.version = child.version; |
124 |
156 |
this.description = child.description; |
125 |
156 |
this.childs = child.childs; |
126 |
42 |
this.modules = child.modules; |
127 |
42 |
} |
128 |
|
} |