root / trunk / build / distribution / IzPack / src / lib / com / izforge / izpack / util / OsVersion.java @ 21757
History | View | Annotate | Download (2.56 KB)
1 |
/*
|
---|---|
2 |
* $Id: OsVersion.java 5819 2006-06-14 07:29:09Z cesar $
|
3 |
* IzPack
|
4 |
* Copyright (C) 2004 Hani Suleiman
|
5 |
*
|
6 |
* File : OsVersion.java
|
7 |
* Description : Helper for OS version handling.
|
8 |
*
|
9 |
* This program is free software; you can redistribute it and/or
|
10 |
* modify it under the terms of the GNU General Public License
|
11 |
* as published by the Free Software Foundation; either version 2
|
12 |
* of the License, or any later version.
|
13 |
*
|
14 |
* This program is distributed in the hope that it will be useful,
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
* GNU General Public License for more details.
|
18 |
*
|
19 |
* You should have received a copy of the GNU General Public License
|
20 |
* along with this program; if not, write to the Free Software
|
21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
22 |
*/
|
23 |
package com.izforge.izpack.util; |
24 |
|
25 |
/**
|
26 |
* Date: Nov 9, 2004 Time: 8:53:22 PM
|
27 |
* @author hani
|
28 |
*/
|
29 |
public final class OsVersion |
30 |
{ |
31 |
public static final String OS_NAME = System.getProperty("os.name"); |
32 |
|
33 |
private static boolean startsWith(String str, String prefix) |
34 |
{ |
35 |
return str != null && str.startsWith(prefix); |
36 |
} |
37 |
|
38 |
private static boolean startsWithIgnoreCase(String str, String prefix) |
39 |
{ |
40 |
return str != null && str.toUpperCase().startsWith(prefix.toUpperCase()); |
41 |
} |
42 |
|
43 |
/**
|
44 |
* True if this is FreeBSD.
|
45 |
*/
|
46 |
public static final boolean IS_FREEBSD = startsWithIgnoreCase(OS_NAME, "FreeBSD"); |
47 |
|
48 |
/**
|
49 |
* True if this is Linux.
|
50 |
*/
|
51 |
public static final boolean IS_LINUX = startsWithIgnoreCase(OS_NAME, "Linux"); |
52 |
|
53 |
/**
|
54 |
* True if this is HP-UX.
|
55 |
*/
|
56 |
public static final boolean IS_HPUX = startsWithIgnoreCase(OS_NAME, "HP-UX"); |
57 |
|
58 |
/**
|
59 |
* True if this is AIX.
|
60 |
*/
|
61 |
public static final boolean IS_AIX = startsWithIgnoreCase(OS_NAME, "AIX"); |
62 |
|
63 |
/**
|
64 |
* True if this is SunOS.
|
65 |
*/
|
66 |
public static final boolean IS_SUNOS = startsWithIgnoreCase(OS_NAME, "SunOS"); |
67 |
|
68 |
/**
|
69 |
* True if this is OS/2.
|
70 |
*/
|
71 |
public static final boolean IS_OS2 = startsWith(OS_NAME, "OS/2"); |
72 |
|
73 |
/**
|
74 |
* True if this is the Mac OS X.
|
75 |
*/
|
76 |
public static final boolean IS_OSX = startsWith(OS_NAME, "Mac") && OS_NAME.endsWith("X"); |
77 |
|
78 |
/**
|
79 |
* True if this is Windows.
|
80 |
*/
|
81 |
public static final boolean IS_WINDOWS = startsWith(OS_NAME, "Windows"); |
82 |
|
83 |
/**
|
84 |
* True if this is some variant of Unix (OSX, Linux, Solaris, FreeBSD, etc).
|
85 |
*/
|
86 |
public static final boolean IS_UNIX = !IS_OS2 && !IS_WINDOWS; |
87 |
} |