--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/unixwork/uwproj/Feature.java Mon Feb 04 15:09:39 2019 +0100 @@ -0,0 +1,99 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package de.unixwork.uwproj; + +import java.util.LinkedList; +import java.util.List; +import org.w3c.dom.Element; + +/** + * + * @author olaf + */ +public class Feature { + private String name; + private String arg; + private boolean def; + + private TargetData targetData; + + public static Feature parse(Project project, Element e) throws Exception { + Feature feature = new Feature(); + String name = e.getAttribute("name"); + String arg = e.getAttribute("arg"); + String def = e.getAttribute("default"); + + if(name.length() == 0) { + throw new Exception("feature element requires name attribute"); + } + + String ld = def.toLowerCase(); + boolean on = ld.equals("on") || ld.equals("true"); + feature.setName(name); + feature.setDefault(on); + if(arg.length() == 0) { + feature.setArg(name); + } else { + feature.setArg(arg); + } + + feature.setTargetData(TargetData.parse(e)); + project.addFeature(feature); + return feature; + } + + public String getVarName() { + return "FEATURE_"+name.toUpperCase(); + } + + public List<String> getDependencies() { + return getTargetData().getDependencies(); + } + + public List<Define> getDefines() { + return getTargetData().getDefines(); + } + + public String getMake() { + return targetData.getMake(); + } + + public boolean hasMake() { + return targetData.getMake().trim().length() > 0; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getArg() { + return arg; + } + + public void setArg(String arg) { + this.arg = arg; + } + + public boolean isDefault() { + return def; + } + + public void setDefault(boolean def) { + this.def = def; + } + + public TargetData getTargetData() { + return targetData; + } + + public void setTargetData(TargetData targetData) { + this.targetData = targetData; + } +}