Class Os
- java.lang.Object
-
- org.codehaus.plexus.interpolation.os.Os
-
public class Os extends java.lang.ObjectNOTE: 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
- Author:
- Stefan Bodewig, Magesh Umasankar, Brian Fox
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringFAMILY_DOSstatic java.lang.StringFAMILY_MACstatic java.lang.StringFAMILY_NETWAREstatic java.lang.StringFAMILY_OPENVMSstatic java.lang.StringFAMILY_OS2static java.lang.StringFAMILY_OS400static java.lang.StringFAMILY_TANDEMstatic java.lang.StringFAMILY_UNIXstatic java.lang.StringFAMILY_WIN9Xstatic java.lang.StringFAMILY_WINDOWSstatic java.lang.StringFAMILY_ZOSstatic java.lang.StringOS_ARCHstatic java.lang.StringOS_FAMILYstatic java.lang.StringOS_NAMEstatic java.lang.StringOS_VERSION
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleaneval()Determines if the current OS matches the type of that set in setFamily.static java.util.Set<java.lang.String>getValidFamilies()static booleanisArch(java.lang.String arch)Determines if the current OS matches the given OS architecture.static booleanisFamily(java.lang.String family)Determines if the current OS matches the given OS family.static booleanisName(java.lang.String name)Determines if the current OS matches the given OS name.static booleanisOs(java.lang.String family, java.lang.String name, java.lang.String arch, java.lang.String version)Determines if the current OS matches the given OS family, name, architecture and version.static booleanisValidFamily(java.lang.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 openvmsstatic booleanisVersion(java.lang.String version)Determines if the current OS matches the given OS version.voidsetArch(java.lang.String arch)Sets the desired OS architecturevoidsetFamily(java.lang.String f)Sets the desired OS family typevoidsetName(java.lang.String name)Sets the desired OS namevoidsetVersion(java.lang.String version)Sets the desired OS version
-
-
-
Field Detail
-
FAMILY_DOS
public static final java.lang.String FAMILY_DOS
- See Also:
- Constant Field Values
-
FAMILY_MAC
public static final java.lang.String FAMILY_MAC
- See Also:
- Constant Field Values
-
FAMILY_NETWARE
public static final java.lang.String FAMILY_NETWARE
- See Also:
- Constant Field Values
-
FAMILY_OS2
public static final java.lang.String FAMILY_OS2
- See Also:
- Constant Field Values
-
FAMILY_TANDEM
public static final java.lang.String FAMILY_TANDEM
- See Also:
- Constant Field Values
-
FAMILY_UNIX
public static final java.lang.String FAMILY_UNIX
- See Also:
- Constant Field Values
-
FAMILY_WINDOWS
public static final java.lang.String FAMILY_WINDOWS
- See Also:
- Constant Field Values
-
FAMILY_WIN9X
public static final java.lang.String FAMILY_WIN9X
- See Also:
- Constant Field Values
-
FAMILY_ZOS
public static final java.lang.String FAMILY_ZOS
- See Also:
- Constant Field Values
-
FAMILY_OS400
public static final java.lang.String FAMILY_OS400
- See Also:
- Constant Field Values
-
FAMILY_OPENVMS
public static final java.lang.String FAMILY_OPENVMS
- See Also:
- Constant Field Values
-
OS_NAME
public static final java.lang.String OS_NAME
-
OS_ARCH
public static final java.lang.String OS_ARCH
-
OS_VERSION
public static final java.lang.String OS_VERSION
-
OS_FAMILY
public static final java.lang.String OS_FAMILY
-
-
Method Detail
-
setFamily
public void setFamily(java.lang.String f)
Sets the desired OS family type- Parameters:
f- The OS family type desired Possible values:- dos
- mac
- netware
- os/2
- tandem
- unix
- windows
- win9x
- z/os
- os/400
- openvms
-
setName
public void setName(java.lang.String name)
Sets the desired OS name- Parameters:
name- The OS name
-
setArch
public void setArch(java.lang.String arch)
Sets the desired OS architecture- Parameters:
arch- The OS architecture
-
setVersion
public void setVersion(java.lang.String version)
Sets the desired OS version- Parameters:
version- The OS version
-
eval
public boolean eval() throws java.lang.ExceptionDetermines if the current OS matches the type of that set in setFamily.- Returns:
- true/false.
- Throws:
java.lang.Exception- in case of an error.- See Also:
setFamily(String)
-
isFamily
public static boolean isFamily(java.lang.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(java.lang.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
-
isArch
public static boolean isArch(java.lang.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
-
isVersion
public static boolean isVersion(java.lang.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
-
isOs
public static boolean isOs(java.lang.String family, java.lang.String name, java.lang.String arch, java.lang.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 familyname- The OS namearch- The OS architectureversion- The OS version- Returns:
- true if the OS matches
- Since:
- 1.0
-
isValidFamily
public static boolean isValidFamily(java.lang.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
- Parameters:
theFamily- the family to check.- Returns:
- true if one of the valid families.
- Since:
- 1.4.2
-
getValidFamilies
public static java.util.Set<java.lang.String> getValidFamilies()
- Returns:
- a copy of the valid families
- Since:
- 1.4.2
-
-