Class Os
- java.lang.Object
-
- org.codehaus.plexus.interpolation.os.Os
-
public class Os extends java.lang.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
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
arch
private java.lang.String
family
static java.lang.String
FAMILY_DOS
static java.lang.String
FAMILY_MAC
static java.lang.String
FAMILY_NETWARE
static java.lang.String
FAMILY_OPENVMS
static java.lang.String
FAMILY_OS2
static java.lang.String
FAMILY_OS400
static java.lang.String
FAMILY_TANDEM
static java.lang.String
FAMILY_UNIX
static java.lang.String
FAMILY_WIN9X
static java.lang.String
FAMILY_WINDOWS
static java.lang.String
FAMILY_ZOS
private java.lang.String
name
static java.lang.String
OS_ARCH
static java.lang.String
OS_FAMILY
static java.lang.String
OS_NAME
static java.lang.String
OS_VERSION
private static java.lang.String
PATH_SEP
private static java.util.Set<java.lang.String>
validFamilies
private java.lang.String
version
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
eval()
Determines if the current OS matches the type of that set in setFamily.private static java.lang.String
getOsFamily()
Helper method to determine the current OS family.static java.util.Set<java.lang.String>
getValidFamilies()
static boolean
isArch(java.lang.String arch)
Determines if the current OS matches the given OS architecture.static boolean
isFamily(java.lang.String family)
Determines if the current OS matches the given OS family.static boolean
isName(java.lang.String name)
Determines if the current OS matches the given OS name.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.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 openvmsstatic boolean
isVersion(java.lang.String version)
Determines if the current OS matches the given OS version.void
setArch(java.lang.String arch)
Sets the desired OS architecturevoid
setFamily(java.lang.String f)
Sets the desired OS family typevoid
setName(java.lang.String name)
Sets the desired OS nameprivate static java.util.Set<java.lang.String>
setValidFamilies()
Initializes the set of valid families.void
setVersion(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
-
validFamilies
private static final java.util.Set<java.lang.String> validFamilies
-
PATH_SEP
private static final java.lang.String PATH_SEP
-
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
-
family
private java.lang.String family
-
name
private java.lang.String name
-
version
private java.lang.String version
-
arch
private java.lang.String arch
-
-
Method Detail
-
setValidFamilies
private static java.util.Set<java.lang.String> setValidFamilies()
Initializes the set of valid families.
-
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.Exception
Determines 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
-
getOsFamily
private static java.lang.String getOsFamily()
Helper method to determine the current OS family.- Returns:
- name of current OS family.
- Since:
- 1.4.2
-
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
-
-