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

Sat, 20 Jan 2024 15:47:39 +0100

author
Mike Becker <universe@uap-core.de>
date
Sat, 20 Jan 2024 15:47:39 +0100
changeset 105
4b3e655339cb
parent 45
f4ec2feccebb
child 113
24f32dbd88cd
permissions
-rw-r--r--

improve toolchain detection

relates to #347

package de.unixwork.uwproj;

import org.w3c.dom.Element;

public class ConfigVar {
    private String varName;
    private String value;
    private boolean exec = false;

    public static ConfigVar parse(Element e) {
        return parse(e, false);
    }

    public static ConfigVar parse(Element e, boolean varNameIsElemName) {
        ConfigVar var = new ConfigVar();

        if (varNameIsElemName) {
            // take the node name literally and don't apply shId()
            var.varName = e.getNodeName().toUpperCase();
        } else {
            String name = e.getAttribute("name");
            if (name.isBlank()) {
                System.err.println("<var>-element: name attribute required");
                return null;
            }
            var.varName = name;
        }

        var.value = Util.getContent(e);
        var.exec = Boolean.parseBoolean(e.getAttribute("exec"));

        return var;
    }

    public String getVarName() {
        return varName;
    }

    public String getValue() {
        return value;
    }

    public boolean isExec() {
        return exec;
    }
}

mercurial