src/main/java/de/unixwork/uwproj/Target.java

changeset 40
b42bfc9e9983
parent 5
895bf81d3b6e
child 41
75ee588d5d9e
equal deleted inserted replaced
39:3ca85da78515 40:b42bfc9e9983
1 /*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6 package de.unixwork.uwproj; 1 package de.unixwork.uwproj;
7 2
8 import java.util.LinkedList;
9 import java.util.List;
10 import org.w3c.dom.Element; 3 import org.w3c.dom.Element;
11 import org.w3c.dom.Node; 4 import org.w3c.dom.Node;
12 import org.w3c.dom.NodeList; 5 import org.w3c.dom.NodeList;
13 6
14 /** 7 import java.util.LinkedList;
15 * 8 import java.util.List;
16 * @author olaf 9
17 */
18 public class Target { 10 public class Target {
19 private String name; 11 private String name;
20 private String prefix; 12 private String prefix;
21 13
22 private List<String> dependencies = new LinkedList<>(); 14 private final List<String> dependencies = new LinkedList<>();
23 private List<String> optionalDependencies = new LinkedList<>(); 15 private final List<String> optionalDependencies = new LinkedList<>();
24 private List<Define> defines = new LinkedList<>(); 16 private final List<Define> defines = new LinkedList<>();
25 private List<Feature> features = new LinkedList<>(); 17 private final List<Feature> features = new LinkedList<>();
26 private List<Option> options = new LinkedList<>(); 18 private final List<Option> options = new LinkedList<>();
27 19
28 private boolean allDependencies = false; 20 private boolean allDependencies = false;
29 21
30 public static Target parse(Project project, Element element) throws Exception { 22 public static Target parse(Project project, Element element) throws Exception {
31 Target target = new Target(); 23 Target target = new Target();
32 24
33 String name = element.getAttribute("name"); 25 String name = element.getAttribute("name");
34 if(name.length() > 0) { 26 if(!name.isEmpty()) {
35 target.setName(name); 27 target.setName(name);
36 } 28 }
37 29
38 NodeList nodes = element.getChildNodes(); 30 NodeList nodes = element.getChildNodes();
39 for(int i=0;i<nodes.getLength();i++) { 31 for(int i=0;i<nodes.getLength();i++) {
45 Feature feature = Feature.parse(project, elm); 37 Feature feature = Feature.parse(project, elm);
46 target.addFeature(feature); 38 target.addFeature(feature);
47 } else if(n.equals("define")) { 39 } else if(n.equals("define")) {
48 String def = elm.getAttribute("name"); 40 String def = elm.getAttribute("name");
49 String defval = elm.getAttribute("value"); 41 String defval = elm.getAttribute("value");
50 if(def == null) { 42 if (def.isBlank()) {
51 throw new Exception("define element requires name attribute"); 43 throw new Exception("define element requires name attribute");
52 } 44 }
53 target.addDefine(def, defval); 45 target.addDefine(def, defval);
54 } else if(n.equals("dependencies")) { 46 } else if(n.equals("dependencies")) {
55 String deps = Xml.getContent(elm); 47 String deps = Util.getContent(elm);
56 String[] dependencies = deps.split(","); 48 String[] dependencies = deps.split(",");
57 for(String dependency : dependencies) { 49 for(String dependency : dependencies) {
58 dependency = dependency.trim(); 50 dependency = dependency.trim();
59 target.addDependency(dependency, false); 51 target.addDependency(dependency, false);
60 } 52 }

mercurial