All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.izforge.izpack.util.OsConstraintHelper Maven / Gradle / Ivy

There is a newer version: 5.2.3
Show newest version
package com.izforge.izpack.util;

import com.izforge.izpack.api.adaptator.IXMLElement;
import com.izforge.izpack.api.data.binding.OsModel;

import java.util.ArrayList;
import java.util.List;

/**
 * Encapsulates OS constraints specified on creation time and allows to check them against the
 * current OS.
 * 

* For example, this is used for <executable>s to check whether the executable is suitable for * the current OS. * * @author Olexij Tkatchenko */ public class OsConstraintHelper { /** * Extract a list of OS constraints from given element. * * @param element parent IXMLElement * @return List of OsModel (or empty List if no constraints found) */ public static List getOsList(IXMLElement element) { // get os info on this executable ArrayList osList = new ArrayList(); for (IXMLElement osElement : element.getChildrenNamed("os")) { osList.add( new OsModel( osElement.getAttribute("arch", null), osElement.getAttribute("family", null), osElement.getAttribute("jre", null), osElement.getAttribute("name", null), osElement.getAttribute("version", null)) ); } // backward compatibility: still support os attribute String osattr = element.getAttribute("os"); if ((osattr != null) && (osattr.length() > 0)) { // add the "os" attribute as a family constraint osList.add( new OsModel(null, osattr, null, null, null) ); } return osList; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy