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

changeset 0
38775db5fdf5
child 5
895bf81d3b6e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/unixwork/uwproj/Dependency.java	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,122 @@
+/*
+ * 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;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ *
+ * @author olaf
+ */
+public class Dependency {
+    private String name;
+    private String platform;
+    
+    private List<Flags> flags = new LinkedList<>();
+    private List<PkgConfigPackage> pkgconfig = new LinkedList<>();
+    private List<String> tests = new LinkedList<>();
+    
+    private boolean abortOnError = false;
+    
+    private int num = 0;
+    
+    public static Dependency parse(Element element) throws Exception {
+        Dependency d = new Dependency();
+        
+        String name = element.getAttribute("name");
+        String platform = element.getAttribute("platform");
+        if(name.length() > 0) {
+            d.setName(name);
+        }
+        if(platform.length() > 0) {
+            d.setPlatform(platform);
+        }
+        
+        NodeList nodes = element.getChildNodes();
+        for(int i=0;i<nodes.getLength();i++) {
+            Node node = nodes.item(i);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                Element elm = (Element)node;
+                String n = elm.getNodeName();
+                if(n.equals("cflags") || n.equals("ldflags")) {
+                    Flags f = Flags.parse(elm);
+                    d.addFlags(f);
+                } else if(n.equals("pkgconfig")) {
+                    PkgConfigPackage pcp = PkgConfigPackage.parse(elm);
+                    d.addPkgconfig(pcp);
+                } else if(n.equals("test")) {
+                    d.tests.add(Xml.getContent(elm));
+                }
+            }
+        }
+        
+        return d;
+    }
+    
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPlatform() {
+        return platform;
+    }
+    
+    public String getPlatformString() {
+        if(platform == null || platform.length() == 0) {
+            return "";
+        } else {
+            return "platform=\""+platform+'"';
+        }
+    }
+
+    public void setPlatform(String platform) {
+        this.platform = platform;
+    }
+
+    public List<Flags> getFlags() {
+        return flags;
+    }
+
+    public void addFlags(Flags flags) {
+        this.flags.add(flags);
+    }
+
+    public List<PkgConfigPackage> getPkgconfig() {
+        return pkgconfig;
+    }
+
+    public void addPkgconfig(PkgConfigPackage pkgconfig) {
+        this.pkgconfig.add(pkgconfig);
+    }
+
+    public boolean isAbortOnError() {
+        return abortOnError;
+    }
+
+    public void setAbortOnError(boolean abortOnError) {
+        this.abortOnError = abortOnError;
+    }
+    
+    public int getNum() {
+        return num;
+    }
+    
+    public void setNum(int num) {
+        this.num = num;
+    }
+    
+    public List<String> getTests() {
+        return tests;
+    }
+}

mercurial