org.codehaus.plexus.interpolation.os

Class Os

public class Os extends Object

NOTE: This class was copied from plexus-utils, to allow this library to stand completely self-contained.
Condition that tests the OS type.

Since: 1.0

Version: $Id: Os.java 7529 2008-07-20 20:24:21Z olamy $

Author: Stefan Bodewig Magesh Umasankar Brian Fox

Field Summary
static StringFAMILY_DOS
static StringFAMILY_MAC
static StringFAMILY_NETWARE
static StringFAMILY_OPENVMS
static StringFAMILY_OS2
static StringFAMILY_OS400
static StringFAMILY_TANDEM
static StringFAMILY_UNIX
static StringFAMILY_WIN9X
static StringFAMILY_WINDOWS
static StringFAMILY_ZOS
static StringOS_ARCH
static StringOS_FAMILY
static StringOS_NAME
static StringOS_VERSION
Constructor Summary
Os()
Default constructor
Os(String family)
Constructor that sets the family attribute
Method Summary
booleaneval()
Determines if the current OS matches the type of that set in setFamily.
static SetgetValidFamilies()
static booleanisArch(String arch)
Determines if the current OS matches the given OS architecture.
static booleanisFamily(String family)
Determines if the current OS matches the given OS family.
static booleanisName(String name)
Determines if the current OS matches the given OS name.
static booleanisOs(String family, String name, String arch, String version)
Determines if the current OS matches the given OS family, name, architecture and version.
static booleanisValidFamily(String theFamily)
Helper method to check if the given family is in the following list:
  • dos
  • mac
  • netware
  • os/2
  • tandem
  • unix
  • windows
  • win9x
  • z/os
  • os/400
  • openvms
static booleanisVersion(String version)
Determines if the current OS matches the given OS version.
voidsetArch(String arch)
Sets the desired OS architecture
voidsetFamily(String f)
Sets the desired OS family type
voidsetName(String name)
Sets the desired OS name
voidsetVersion(String version)
Sets the desired OS version

Field Detail

FAMILY_DOS

public static final String FAMILY_DOS

FAMILY_MAC

public static final String FAMILY_MAC

FAMILY_NETWARE

public static final String FAMILY_NETWARE

FAMILY_OPENVMS

public static final String FAMILY_OPENVMS

FAMILY_OS2

public static final String FAMILY_OS2

FAMILY_OS400

public static final String FAMILY_OS400

FAMILY_TANDEM

public static final String FAMILY_TANDEM

FAMILY_UNIX

public static final String FAMILY_UNIX

FAMILY_WIN9X

public static final String FAMILY_WIN9X

FAMILY_WINDOWS

public static final String FAMILY_WINDOWS

FAMILY_ZOS

public static final String FAMILY_ZOS

OS_ARCH

public static final String OS_ARCH

OS_FAMILY

public static final String OS_FAMILY

OS_NAME

public static final String OS_NAME

OS_VERSION

public static final String OS_VERSION

Constructor Detail

Os

public Os()
Default constructor

Os

public Os(String family)
Constructor that sets the family attribute

Parameters: family a String value

Method Detail

eval

public boolean eval()
Determines if the current OS matches the type of that set in setFamily.

See Also: setFamily

getValidFamilies

public static Set getValidFamilies()

Returns: a copy of the valid families

Since: 1.4.2

isArch

public static boolean isArch(String arch)
Determines if the current OS matches the given OS architecture.

Parameters: arch the OS architecture to check for

Returns: true if the OS matches

Since: 1.0

isFamily

public static boolean isFamily(String family)
Determines if the current OS matches the given OS family.

Parameters: family the family to check for

Returns: true if the OS matches

Since: 1.0

isName

public static boolean isName(String name)
Determines if the current OS matches the given OS name.

Parameters: name the OS name to check for

Returns: true if the OS matches

Since: 1.0

isOs

public static boolean isOs(String family, String name, String arch, String version)
Determines if the current OS matches the given OS family, name, architecture and version. The name, archictecture and version are compared to the System properties os.name, os.version and os.arch in a case-independent way.

Parameters: family The OS family name The OS name arch The OS architecture version The OS version

Returns: true if the OS matches

Since: 1.0

isValidFamily

public static boolean isValidFamily(String theFamily)
Helper method to check if the given family is in the following list:

Parameters: theFamily the family to check.

Returns: true if one of the valid families.

Since: 1.4.2

isVersion

public static boolean isVersion(String version)
Determines if the current OS matches the given OS version.

Parameters: version the OS version to check for

Returns: true if the OS matches

Since: 1.0

setArch

public void setArch(String arch)
Sets the desired OS architecture

Parameters: arch The OS architecture

setFamily

public void setFamily(String f)
Sets the desired OS family type

Parameters: f The OS family type desired
Possible values:

setName

public void setName(String name)
Sets the desired OS name

Parameters: name The OS name

setVersion

public void setVersion(String version)
Sets the desired OS version

Parameters: version The OS version

Copyright © 2001-2009 Codehaus. All Rights Reserved.