Top Description Fields Constructors Methods
org.apache.tools.ant.taskdefs.condition

public Class Os

extends Object
implements Condition
Class Inheritance
All Implemented Interfaces
org.apache.tools.ant.taskdefs.condition.Condition
Imports
java.io.File, java.util.Locale, org.apache.tools.ant.BuildException

Condition that tests the OS type.
Since
Ant 1.4

Field Summary

Modifier and TypeField and Description
private String
arch

OS architecture

private static final String
DARWIN

OpenJDK is reported to call MacOS X "Darwin"

private String
family

OS family to look for

public static final String
FAMILY_9X

OS family that can be tested for.

public static final String
FAMILY_DOS

OS family that can be tested for.

public static final String
FAMILY_MAC

OS family that can be tested for.

public static final String
FAMILY_NETWARE

OS family that can be tested for.

public static final String
FAMILY_NT

OS family that can be tested for.

public static final String
FAMILY_OS2

OS family that can be tested for.

public static final String
FAMILY_OS400

OS family that can be tested for.

public static final String
FAMILY_TANDEM

OS family that can be tested for.

public static final String
FAMILY_UNIX

OS family that can be tested for.

public static final String
FAMILY_VMS

OS family that can be tested for.

public static final String
FAMILY_WINDOWS

OS family that can be tested for.

public static final String
FAMILY_ZOS

OS family that can be tested for.

private String
name

Name of OS

private static final String
private static final String
private static final String
private static final String
private String
version

version of OS

Constructor Summary

AccessConstructor and Description
public
Os()

Default constructor

public
Os(String
a String value
family
)

Constructor that sets the family attribute

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the os matches.
eval
()

Implements org.apache.tools.ant.taskdefs.condition.Condition.eval.

Determines if the OS on which Ant is executing matches the type of that set in setFamily.
public static boolean

Returns:

true if the OS matches
isArch
(String
the OS architecture to check for
arch
)

Determines if the OS on which Ant is executing matches the given OS architecture.

public static boolean

Returns:

true if the OS matches
isFamily
(String
the family to check for
family
)

Determines if the OS on which Ant is executing matches the given OS family.

public static boolean

Returns:

true if the OS matches
isName
(String
the OS name to check for
name
)

Determines if the OS on which Ant is executing matches the given OS name.

public static boolean

Returns:

true if the OS matches
isOs
(String
The OS family
family
,
String
The OS name
name
,
String
The OS architecture
arch
,
String
The OS version
version
)

Determines if the OS on which Ant is executing matches the given OS family, name, architecture and version

public static boolean

Returns:

true if the OS matches
isVersion
(String
the OS version to check for
version
)

Determines if the OS on which Ant is executing matches the given OS version.

public void
setArch(String
The OS architecture
arch
)

Sets the desired OS architecture

public void
setFamily(String
The OS family type desired

Possible values:

  • dos
  • mac
  • netware
  • os/2
  • tandem
  • unix
  • windows
  • win9x
  • z/os
  • os/400
f
)

Sets the desired OS family type

public void
setName(String
The OS name
name
)

Sets the desired OS name

public void
setVersion(String
The OS version
version
)

Sets the desired OS version

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

archback to summary
private String arch

OS architecture

DARWINback to summary
private static final String DARWIN

OpenJDK is reported to call MacOS X "Darwin"

See Also
Bugzilla, Jira
familyback to summary
private String family

OS family to look for

FAMILY_9Xback to summary
public static final String FAMILY_9X

OS family that can be tested for. win9x

FAMILY_DOSback to summary
public static final String FAMILY_DOS

OS family that can be tested for. dos

FAMILY_MACback to summary
public static final String FAMILY_MAC

OS family that can be tested for. mac

FAMILY_NETWAREback to summary
public static final String FAMILY_NETWARE

OS family that can be tested for. netware

FAMILY_NTback to summary
public static final String FAMILY_NT

OS family that can be tested for. winnt

FAMILY_OS2back to summary
public static final String FAMILY_OS2

OS family that can be tested for. os/2

FAMILY_OS400back to summary
public static final String FAMILY_OS400

OS family that can be tested for. os/400

FAMILY_TANDEMback to summary
public static final String FAMILY_TANDEM

OS family that can be tested for. tandem

FAMILY_UNIXback to summary
public static final String FAMILY_UNIX

OS family that can be tested for. unix

FAMILY_VMSback to summary
public static final String FAMILY_VMS

OS family that can be tested for. openvms

FAMILY_WINDOWSback to summary
public static final String FAMILY_WINDOWS

OS family that can be tested for. windows

FAMILY_ZOSback to summary
public static final String FAMILY_ZOS

OS family that can be tested for. z/os

nameback to summary
private String name

Name of OS

OS_ARCHback to summary
private static final String OS_ARCH
OS_NAMEback to summary
private static final String OS_NAME
OS_VERSIONback to summary
private static final String OS_VERSION
PATH_SEPback to summary
private static final String PATH_SEP
versionback to summary
private String version

version of OS

Constructor Detail

Osback to summary
public Os()

Default constructor

Osback to summary
public Os(String family)

Constructor that sets the family attribute

Parameters
family:String

a String value

Method Detail

evalback to summary
public boolean eval() throws BuildException

Implements org.apache.tools.ant.taskdefs.condition.Condition.eval.

Determines if the OS on which Ant is executing matches the type of that set in setFamily.

Returns:boolean

true if the os matches.

Annotations
@Override
Exceptions
BuildException:
if there is an error.
See Also
Os#setFamily(String)
isArchback to summary
public static boolean isArch(String arch)

Determines if the OS on which Ant is executing matches the given OS architecture.

Parameters
arch:String

the OS architecture to check for

Returns:boolean

true if the OS matches

Since
1.7
isFamilyback to summary
public static boolean isFamily(String family)

Determines if the OS on which Ant is executing matches the given OS family.

Parameters
family:String

the family to check for

Returns:boolean

true if the OS matches

Since
1.5
isNameback to summary
public static boolean isName(String name)

Determines if the OS on which Ant is executing matches the given OS name.

Parameters
name:String

the OS name to check for

Returns:boolean

true if the OS matches

Since
1.7
isOsback to summary
public static boolean isOs(String family, String name, String arch, String version)

Determines if the OS on which Ant is executing matches the given OS family, name, architecture and version

Parameters
family:String

The OS family

name:String

The OS name

arch:String

The OS architecture

version:String

The OS version

Returns:boolean

true if the OS matches

Since
1.7
isVersionback to summary
public static boolean isVersion(String version)

Determines if the OS on which Ant is executing matches the given OS version.

Parameters
version:String

the OS version to check for

Returns:boolean

true if the OS matches

Since
1.7
setArchback to summary
public void setArch(String arch)

Sets the desired OS architecture

Parameters
arch:String

The OS architecture

setFamilyback to summary
public void setFamily(String f)

Sets the desired OS family type

Parameters
f:String

The OS family type desired

Possible values:

  • dos
  • mac
  • netware
  • os/2
  • tandem
  • unix
  • windows
  • win9x
  • z/os
  • os/400
setNameback to summary
public void setName(String name)

Sets the desired OS name

Parameters
name:String

The OS name

setVersionback to summary
public void setVersion(String version)

Sets the desired OS version

Parameters
version:String

The OS version