|
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; |
|
7 |
|
8 import java.util.LinkedList; |
|
9 import java.util.List; |
|
10 import org.w3c.dom.Element; |
|
11 import org.w3c.dom.Node; |
|
12 import org.w3c.dom.NodeList; |
|
13 |
|
14 /** |
|
15 * |
|
16 * @author olaf |
|
17 */ |
|
18 public class Dependency { |
|
19 private String name; |
|
20 private String platform; |
|
21 |
|
22 private List<Flags> flags = new LinkedList<>(); |
|
23 private List<PkgConfigPackage> pkgconfig = new LinkedList<>(); |
|
24 private List<String> tests = new LinkedList<>(); |
|
25 |
|
26 private boolean abortOnError = false; |
|
27 |
|
28 private int num = 0; |
|
29 |
|
30 public static Dependency parse(Element element) throws Exception { |
|
31 Dependency d = new Dependency(); |
|
32 |
|
33 String name = element.getAttribute("name"); |
|
34 String platform = element.getAttribute("platform"); |
|
35 if(name.length() > 0) { |
|
36 d.setName(name); |
|
37 } |
|
38 if(platform.length() > 0) { |
|
39 d.setPlatform(platform); |
|
40 } |
|
41 |
|
42 NodeList nodes = element.getChildNodes(); |
|
43 for(int i=0;i<nodes.getLength();i++) { |
|
44 Node node = nodes.item(i); |
|
45 if (node.getNodeType() == Node.ELEMENT_NODE) { |
|
46 Element elm = (Element)node; |
|
47 String n = elm.getNodeName(); |
|
48 if(n.equals("cflags") || n.equals("ldflags")) { |
|
49 Flags f = Flags.parse(elm); |
|
50 d.addFlags(f); |
|
51 } else if(n.equals("pkgconfig")) { |
|
52 PkgConfigPackage pcp = PkgConfigPackage.parse(elm); |
|
53 d.addPkgconfig(pcp); |
|
54 } else if(n.equals("test")) { |
|
55 d.tests.add(Xml.getContent(elm)); |
|
56 } |
|
57 } |
|
58 } |
|
59 |
|
60 return d; |
|
61 } |
|
62 |
|
63 public String getName() { |
|
64 return name; |
|
65 } |
|
66 |
|
67 public void setName(String name) { |
|
68 this.name = name; |
|
69 } |
|
70 |
|
71 public String getPlatform() { |
|
72 return platform; |
|
73 } |
|
74 |
|
75 public String getPlatformString() { |
|
76 if(platform == null || platform.length() == 0) { |
|
77 return ""; |
|
78 } else { |
|
79 return "platform=\""+platform+'"'; |
|
80 } |
|
81 } |
|
82 |
|
83 public void setPlatform(String platform) { |
|
84 this.platform = platform; |
|
85 } |
|
86 |
|
87 public List<Flags> getFlags() { |
|
88 return flags; |
|
89 } |
|
90 |
|
91 public void addFlags(Flags flags) { |
|
92 this.flags.add(flags); |
|
93 } |
|
94 |
|
95 public List<PkgConfigPackage> getPkgconfig() { |
|
96 return pkgconfig; |
|
97 } |
|
98 |
|
99 public void addPkgconfig(PkgConfigPackage pkgconfig) { |
|
100 this.pkgconfig.add(pkgconfig); |
|
101 } |
|
102 |
|
103 public boolean isAbortOnError() { |
|
104 return abortOnError; |
|
105 } |
|
106 |
|
107 public void setAbortOnError(boolean abortOnError) { |
|
108 this.abortOnError = abortOnError; |
|
109 } |
|
110 |
|
111 public int getNum() { |
|
112 return num; |
|
113 } |
|
114 |
|
115 public void setNum(int num) { |
|
116 this.num = num; |
|
117 } |
|
118 |
|
119 public List<String> getTests() { |
|
120 return tests; |
|
121 } |
|
122 } |