|
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 |
|
12 /** |
|
13 * |
|
14 * @author olaf |
|
15 */ |
|
16 public class Feature { |
|
17 private String name; |
|
18 private String arg; |
|
19 private boolean def; |
|
20 |
|
21 private TargetData targetData; |
|
22 |
|
23 public static Feature parse(Project project, Element e) throws Exception { |
|
24 Feature feature = new Feature(); |
|
25 String name = e.getAttribute("name"); |
|
26 String arg = e.getAttribute("arg"); |
|
27 String def = e.getAttribute("default"); |
|
28 |
|
29 if(name.length() == 0) { |
|
30 throw new Exception("feature element requires name attribute"); |
|
31 } |
|
32 |
|
33 String ld = def.toLowerCase(); |
|
34 boolean on = ld.equals("on") || ld.equals("true"); |
|
35 feature.setName(name); |
|
36 feature.setDefault(on); |
|
37 if(arg.length() == 0) { |
|
38 feature.setArg(name); |
|
39 } else { |
|
40 feature.setArg(arg); |
|
41 } |
|
42 |
|
43 feature.setTargetData(TargetData.parse(e)); |
|
44 project.addFeature(feature); |
|
45 return feature; |
|
46 } |
|
47 |
|
48 public String getVarName() { |
|
49 return "FEATURE_"+name.toUpperCase(); |
|
50 } |
|
51 |
|
52 public List<String> getDependencies() { |
|
53 return getTargetData().getDependencies(); |
|
54 } |
|
55 |
|
56 public List<Define> getDefines() { |
|
57 return getTargetData().getDefines(); |
|
58 } |
|
59 |
|
60 public String getMake() { |
|
61 return targetData.getMake(); |
|
62 } |
|
63 |
|
64 public boolean hasMake() { |
|
65 return targetData.getMake().trim().length() > 0; |
|
66 } |
|
67 |
|
68 public String getName() { |
|
69 return name; |
|
70 } |
|
71 |
|
72 public void setName(String name) { |
|
73 this.name = name; |
|
74 } |
|
75 |
|
76 public String getArg() { |
|
77 return arg; |
|
78 } |
|
79 |
|
80 public void setArg(String arg) { |
|
81 this.arg = arg; |
|
82 } |
|
83 |
|
84 public boolean isDefault() { |
|
85 return def; |
|
86 } |
|
87 |
|
88 public void setDefault(boolean def) { |
|
89 this.def = def; |
|
90 } |
|
91 |
|
92 public TargetData getTargetData() { |
|
93 return targetData; |
|
94 } |
|
95 |
|
96 public void setTargetData(TargetData targetData) { |
|
97 this.targetData = targetData; |
|
98 } |
|
99 } |