001: package com.jeta.swingbuilder.gui.utils;
002:
003: import java.security.AccessControlException;
004:
005: /**
006: * Utility class for determining what OS Abeille is running on.
007: *
008: * @author Todd Viegut
009: * @since Abeille 2.1 M1
010: * @version 1.0, 08.28.2007
011: */
012: public final class OSUtils {
013:
014: private static boolean isMacClassic = false;
015: private static boolean isMacOSX = false;
016: //
017: private static boolean isWindows;
018: private static boolean isWindowsNTor2000 = false;
019: private static boolean isWindowsXP = false;
020: private static boolean isWindows2003 = false;
021: private static boolean isClassicWindows = false;
022: private static boolean isWindows95 = false;
023: private static boolean isWindows98 = false;
024: //
025: private static boolean isLinux = false;
026: private static boolean isSolaris = false;
027:
028: static {
029: isWindows = false;
030: String s = getProperty("os.name", "Windows XP");
031: isWindows = s.indexOf("Windows") != -1;
032: try {
033: String s1 = getProperty("os.version", "5.0");
034: Float float1 = Float.valueOf(s1);
035: isClassicWindows = (double) float1.floatValue() <= 4D;
036: } catch (NumberFormatException numberformatexception) {
037: isClassicWindows = false;
038: }
039: if (s.indexOf("Windows XP") != -1
040: || s.indexOf("Windows NT") != -1
041: || s.indexOf("Windows 2000") != -1)
042: isWindowsNTor2000 = true;
043: if (s.indexOf("Windows XP") != -1)
044: isWindowsXP = true;
045: if (s.indexOf("Windows 2003") != -1) {
046: isWindows2003 = true;
047: isWindowsXP = true;
048: }
049: if (s.indexOf("Windows 95") != -1)
050: isWindows95 = true;
051: if (s.indexOf("Windows 98") != -1)
052: isWindows98 = true;
053: isSolaris = s.indexOf("Solaris") != -1
054: || s.indexOf("SunOS") != -1;
055: isLinux = s.indexOf("Linux") != -1;
056: if (s.startsWith("Mac OS"))
057: if (s.endsWith("X"))
058: isMacOSX = true;
059: else
060: isMacClassic = true;
061: }
062:
063: private OSUtils() {
064: }
065:
066: private static String getProperty(String key, String defaultValue) {
067: try {
068: return System.getProperty(key);
069: } catch (AccessControlException ace) {
070: return defaultValue;
071: }
072: }
073:
074: public static boolean isWindows() {
075: return isWindows;
076: }
077:
078: public static boolean isClassicWindows() {
079: return isClassicWindows;
080: }
081:
082: public static boolean isWindowsNTor2000() {
083: return isWindowsNTor2000;
084: }
085:
086: public static boolean isWindowsXP() {
087: return isWindowsXP;
088: }
089:
090: public static boolean isWindows95() {
091: return isWindows95;
092: }
093:
094: public static boolean isWindows98() {
095: return isWindows98;
096: }
097:
098: public static boolean isWindows2003() {
099: return isWindows2003;
100: }
101:
102: public static boolean isMacClassic() {
103: return isMacClassic;
104: }
105:
106: public static boolean isMacOSX() {
107: return isMacOSX;
108: }
109:
110: public static boolean isAnyMac() {
111: return isMacClassic || isMacOSX;
112: }
113:
114: public static boolean isSolaris() {
115: return isSolaris;
116: }
117:
118: public static boolean isLinux() {
119: return isLinux;
120: }
121:
122: public static boolean isUnix() {
123: return isLinux || isSolaris;
124: }
125: }
|