com.izforge.izpack.util
Class OsConstraint

java.lang.Object
  extended by com.izforge.izpack.util.OsConstraint
All Implemented Interfaces:
java.io.Serializable

public class OsConstraint
extends java.lang.Object
implements java.io.Serializable

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
See Also:
Serialized Form

Field Summary
private  java.lang.String arch
          OS architecture from java system properties
private  java.lang.String family
          The OS family
private  java.lang.String name
          OS name from java system properties
private static long serialVersionUID
           
private  java.lang.String version
          OS version from java system properties
 
Constructor Summary
OsConstraint(java.lang.String family, java.lang.String name, java.lang.String version, java.lang.String arch)
          Constructs a new instance.
 
Method Summary
 java.lang.String getArch()
           
 java.lang.String getFamily()
           
 java.lang.String getName()
           
static java.util.List getOsList(XMLElement element)
          Extract a list of OS constraints from given element.
 java.lang.String getVersion()
           
 boolean matchCurrentSystem()
          Matches OS specification in this class against current system properties.
static boolean oneMatchesCurrentSystem(java.util.List constraint_list)
          Helper function: Scan a list of OsConstraints for a match.
static boolean oneMatchesCurrentSystem(XMLElement el)
          Helper function: Check whether the given XMLElement is "suitable" for the current OS.
 void setArch(java.lang.String a)
           
 void setFamily(java.lang.String f)
           
 void setName(java.lang.String n)
           
 void setVersion(java.lang.String v)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

family

private java.lang.String family
The OS family


name

private java.lang.String name
OS name from java system properties


version

private java.lang.String version
OS version from java system properties


arch

private java.lang.String arch
OS architecture from java system properties

Constructor Detail

OsConstraint

public OsConstraint(java.lang.String family,
                    java.lang.String name,
                    java.lang.String version,
                    java.lang.String arch)
Constructs a new instance. Please remember, MacOSX belongs to Unix family.

Parameters:
family - The OS family (unix, windows or mac).
name - The exact OS name.
version - The exact OS version (check property os.version for values).
arch - The machine architecture (check property os.arch for values).
Method Detail

matchCurrentSystem

public boolean matchCurrentSystem()
Matches OS specification in this class against current system properties.

Returns:
Description of the Return Value

getOsList

public static java.util.List getOsList(XMLElement element)
Extract a list of OS constraints from given element.

Parameters:
element - parent XMLElement
Returns:
List of OsConstraint (or empty List if no constraints found)

oneMatchesCurrentSystem

public static boolean oneMatchesCurrentSystem(java.util.List constraint_list)
Helper function: Scan a list of OsConstraints for a match.

Parameters:
constraint_list - List of OsConstraint to check
Returns:
true if one of the OsConstraints matched the current system or constraint_list is null (no constraints), false if none of the OsConstraints matched

oneMatchesCurrentSystem

public static boolean oneMatchesCurrentSystem(XMLElement el)
Helper function: Check whether the given XMLElement is "suitable" for the current OS.

Parameters:
el - The XMLElement to check for OS constraints.
Returns:
true if there were no OS constraints or the constraints matched the current OS.

setFamily

public void setFamily(java.lang.String f)

getFamily

public java.lang.String getFamily()

setName

public void setName(java.lang.String n)

getName

public java.lang.String getName()

setVersion

public void setVersion(java.lang.String v)

getVersion

public java.lang.String getVersion()

setArch

public void setArch(java.lang.String a)

getArch

public java.lang.String getArch()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object