Fields Summary |
---|
private static final String | OS_NAME |
private static final String | OS_ARCH |
private static final String | OS_VERSION |
private static final String | PATH_SEP |
private String | familyOS family to look for |
private String | nameName of OS |
private String | versionversion of OS |
private String | archOS architecture |
public static final String | FAMILY_WINDOWSOS family that can be tested for. {@value} |
public static final String | FAMILY_9XOS family that can be tested for. {@value} |
public static final String | FAMILY_NTOS family that can be tested for. {@value} |
public static final String | FAMILY_OS2OS family that can be tested for. {@value} |
public static final String | FAMILY_NETWAREOS family that can be tested for. {@value} |
public static final String | FAMILY_DOSOS family that can be tested for. {@value} |
public static final String | FAMILY_MACOS family that can be tested for. {@value} |
public static final String | FAMILY_TANDEMOS family that can be tested for. {@value} |
public static final String | FAMILY_UNIXOS family that can be tested for. {@value} |
public static final String | FAMILY_VMSOS family that can be tested for. {@value} |
public static final String | FAMILY_ZOSOS family that can be tested for. {@value} |
public static final String | FAMILY_OS400OS family that can be tested for. {@value} |
Methods Summary |
---|
public boolean | eval()Determines if the OS on which Ant is executing matches the type of
that set in setFamily.
return isOs(family, name, arch, version);
|
public static boolean | isArch(java.lang.String arch)Determines if the OS on which Ant is executing matches the
given OS architecture.
return isOs(null, null, arch, null);
|
public static boolean | isFamily(java.lang.String family)Determines if the OS on which Ant is executing matches the
given OS family.
return isOs(family, null, null, null);
|
public static boolean | isName(java.lang.String name)Determines if the OS on which Ant is executing matches the
given OS name.
return isOs(null, name, null, null);
|
public static boolean | isOs(java.lang.String family, java.lang.String name, java.lang.String arch, java.lang.String version)Determines if the OS on which Ant is executing matches the
given OS family, name, architecture and version
boolean retValue = false;
if (family != null || name != null || arch != null
|| version != null) {
boolean isFamily = true;
boolean isName = true;
boolean isArch = true;
boolean isVersion = true;
if (family != null) {
//windows probing logic relies on the word 'windows' in
//the OS
boolean isWindows = OS_NAME.indexOf(FAMILY_WINDOWS) > -1;
boolean is9x = false;
boolean isNT = false;
if (isWindows) {
//there are only four 9x platforms that we look for
is9x = (OS_NAME.indexOf("95") >= 0
|| OS_NAME.indexOf("98") >= 0
|| OS_NAME.indexOf("me") >= 0
//wince isn't really 9x, but crippled enough to
//be a muchness. Ant doesnt run on CE, anyway.
|| OS_NAME.indexOf("ce") >= 0);
isNT = !is9x;
}
if (family.equals(FAMILY_WINDOWS)) {
isFamily = isWindows;
} else if (family.equals(FAMILY_9X)) {
isFamily = isWindows && is9x;
} else if (family.equals(FAMILY_NT)) {
isFamily = isWindows && isNT;
} else if (family.equals(FAMILY_OS2)) {
isFamily = OS_NAME.indexOf(FAMILY_OS2) > -1;
} else if (family.equals(FAMILY_NETWARE)) {
isFamily = OS_NAME.indexOf(FAMILY_NETWARE) > -1;
} else if (family.equals(FAMILY_DOS)) {
isFamily = PATH_SEP.equals(";") && !isFamily(FAMILY_NETWARE);
} else if (family.equals(FAMILY_MAC)) {
isFamily = OS_NAME.indexOf(FAMILY_MAC) > -1;
} else if (family.equals(FAMILY_TANDEM)) {
isFamily = OS_NAME.indexOf("nonstop_kernel") > -1;
} else if (family.equals(FAMILY_UNIX)) {
isFamily = PATH_SEP.equals(":")
&& !isFamily(FAMILY_VMS)
&& (!isFamily(FAMILY_MAC) || OS_NAME.endsWith("x"));
} else if (family.equals(FAMILY_ZOS)) {
isFamily = OS_NAME.indexOf(FAMILY_ZOS) > -1
|| OS_NAME.indexOf("os/390") > -1;
} else if (family.equals(FAMILY_OS400)) {
isFamily = OS_NAME.indexOf(FAMILY_OS400) > -1;
} else if (family.equals(FAMILY_VMS)) {
isFamily = OS_NAME.indexOf(FAMILY_VMS) > -1;
} else {
throw new BuildException(
"Don\'t know how to detect os family \""
+ family + "\"");
}
}
if (name != null) {
isName = name.equals(OS_NAME);
}
if (arch != null) {
isArch = arch.equals(OS_ARCH);
}
if (version != null) {
isVersion = version.equals(OS_VERSION);
}
retValue = isFamily && isName && isArch && isVersion;
}
return retValue;
|
public static boolean | isVersion(java.lang.String version)Determines if the OS on which Ant is executing matches the
given OS version.
return isOs(null, null, null, version);
|
public void | setArch(java.lang.String arch)Sets the desired OS architecture
this.arch = arch.toLowerCase(Locale.US);
|
public void | setFamily(java.lang.String f)Sets the desired OS family type
family = f.toLowerCase(Locale.US);
|
public void | setName(java.lang.String name)Sets the desired OS name
this.name = name.toLowerCase(Locale.US);
|
public void | setVersion(java.lang.String version)Sets the desired OS version
this.version = version.toLowerCase(Locale.US);
|