001: //The contents of this file are subject to the Mozilla Public License Version 1.1
002: //(the "License"); you may not use this file except in compliance with the
003: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004: //
005: //Software distributed under the License is distributed on an "AS IS" basis,
006: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007: //for the specific language governing rights and
008: //limitations under the License.
009: //
010: //The Original Code is "The Columba Project"
011: //
012: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
014: //
015: //All Rights Reserved.
016:
017: package org.columba.core.base;
018:
019: /**
020: * This is a helper class providing a quick and easy way to obtain useful
021: * information about the operating system Columba is running on.
022: *
023: * @author Hrk (Luca Santarelli) <hrk@users.sourceforge.net>
024: */
025: public class OSInfo {
026: private static final String OS_NAME = "os.name"; //$NON-NLS-1$
027:
028: private static final String OS_ARCH = "os.arch"; //$NON-NLS-1$
029:
030: // Platform identifiers: Windows, Linux, Mac OS, ...
031:
032: /**
033: * Returns whether the underlying operating system is a Windows or Windows
034: * NT platform.
035: *
036: * @return isWindows32Platform
037: *
038: * @see #org.columba.core.base.OSInfo.isWindowsPlatform()
039: * @see #org.columba.core.base.OSInfo.isWinNTPlatform()
040: */
041: public static boolean isWin32Platform() {
042: return (isWindowsPlatform() || isWinNTPlatform());
043: }
044:
045: /**
046: * Returns whether the underlying operating system is a Windows NT platform.
047: *
048: * @return isWinNTPlatform
049: *
050: * @see #org.columba.core.base.OSInfo.isWinNT()
051: * @see #org.columba.core.base.OSInfo.isWin2K()
052: * @see #org.columba.core.base.OSInfo.isWin2K3()
053: * @see #org.columba.core.base.OSInfo.isWinXP()
054: */
055: public static boolean isWinNTPlatform() {
056: return (isWinNT() || isWin2K() || isWin2K3() || isWinXP());
057: }
058:
059: /**
060: * Returns whether the underlying operating system is a Windows platform.
061: *
062: * @return isWindowsPlatform
063: *
064: * @see #org.columba.core.base.OSInfo.isWin95()
065: * @see #org.columba.core.base.OSInfo.isWin98()
066: * @see #org.columba.core.base.OSInfo.isWinME()
067: */
068: public static boolean isWindowsPlatform() {
069: return (isWin95() || isWin98() || isWinME());
070: }
071:
072: // Single OS identifiers: Window 95, Window 98, ...
073:
074: /**
075: * Returns whether the underlying operating system is Windows 95.
076: *
077: * @return isWin95
078: */
079: public static boolean isWin95() {
080: return "Windows 95".equalsIgnoreCase(System.getProperty(OS_NAME)); //$NON-NLS-1$
081: }
082:
083: /**
084: * Returns whether the underlying operating system is Windows 98.
085: *
086: * @return isWin98
087: */
088: public static boolean isWin98() {
089: return "Windows 98".equalsIgnoreCase(System.getProperty(OS_NAME)); //$NON-NLS-1$
090: }
091:
092: /**
093: * Returns whether the underlying operating system is Windows ME.
094: *
095: * @return isWinME
096: */
097: public static boolean isWinME() {
098: return "Windows ME".equalsIgnoreCase(System.getProperty(OS_NAME)); //$NON-NLS-1$
099: }
100:
101: /**
102: * Returns whether the underlying operating system is Windows NT.
103: *
104: * @return isWinNT
105: */
106: public static boolean isWinNT() {
107: return "Windows NT".equalsIgnoreCase(System.getProperty(OS_NAME)); //$NON-NLS-1$
108: }
109:
110: /**
111: * Returns whether the underlying operating system is Windows 2000.
112: *
113: * @return isWin2K
114: */
115: public static boolean isWin2K() {
116: return "Windows 2000".equalsIgnoreCase(System.getProperty(OS_NAME)); //$NON-NLS-1$
117: }
118:
119: /**
120: * Returns whether the underlying operating system is Windows 2003.
121: *
122: * @return isWin2K3
123: */
124: public static boolean isWin2K3() {
125: return "Windows 2003".equalsIgnoreCase(System.getProperty(OS_NAME)); //$NON-NLS-1$
126: }
127:
128: /**
129: * Returns whether the underlying operating system is Windows XP.
130: *
131: * @return isWinXP
132: */
133: public static boolean isWinXP() {
134: return "Windows XP".equalsIgnoreCase(System.getProperty(OS_NAME)); //$NON-NLS-1$
135: }
136:
137: /**
138: * Returns whether the underlying operating system is Linux.
139: *
140: * @return isLinux
141: */
142: public static boolean isLinux() {
143: return "Linux".equalsIgnoreCase(System.getProperty(OS_NAME)); //$NON-NLS-1$
144: }
145:
146: /**
147: * Returns whether the underlying operating system is Solaris.
148: *
149: * @return isSolaris
150: */
151: public static boolean isSolaris() {
152: return "Solaris".equalsIgnoreCase(System.getProperty(OS_NAME)); //$NON-NLS-1$
153: }
154:
155: /**
156: * Returns whether the underlying operating system is some MacOS.
157: *
158: * @return isMac
159: */
160: public static boolean isMac() {
161: return System.getProperty(OS_NAME).toLowerCase().indexOf("mac") != -1; //$NON-NLS-1$
162: }
163:
164: public static boolean isAMD64Bit() {
165: return System.getProperty(OS_ARCH).toLowerCase().indexOf(
166: "amd64") != -1; //$NON-NLS-1$
167: }
168: }
|