001: /*
002: * Platform.java
003: *
004: * Copyright (C) 1998-2004 Peter Graves
005: * $Id: Platform.java,v 1.5 2004/06/09 23:44:24 piso Exp $
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: */
021:
022: package org.armedbear.j;
023:
024: public final class Platform {
025: private static final String osName = System.getProperty("os.name");
026: private static final boolean isPlatformLinux = osName
027: .startsWith("Linux");
028: private static final boolean isPlatformUnix = isPlatformLinux
029: || osName.startsWith("Mac OS X")
030: || osName.startsWith("Solaris")
031: || osName.startsWith("SunOS") || osName.startsWith("AIX");
032: private static final boolean isPlatformWindows = osName
033: .startsWith("Windows");
034: private static final boolean isJava13 = System.getProperty(
035: "java.version").startsWith("1.3");
036: private static final boolean isJava14 = System.getProperty(
037: "java.version").startsWith("1.4");
038: private static final boolean isJava140 = System.getProperty(
039: "java.version").startsWith("1.4.0");
040:
041: public static final boolean isPlatformLinux() {
042: return isPlatformLinux;
043: }
044:
045: public static final boolean isPlatformUnix() {
046: return isPlatformUnix;
047: }
048:
049: public static final boolean isPlatformWindows() {
050: return isPlatformWindows;
051: }
052:
053: public static final boolean isPlatformMacOSX() {
054: return osName.startsWith("Mac OS X");
055: }
056:
057: public static final boolean isPlatformWindows5() {
058: if (!isPlatformWindows)
059: return false;
060: final String version = System.getProperty("os.version");
061: int index = version.indexOf('.');
062: final String s = index >= 0 ? version.substring(0, index)
063: : version;
064: try {
065: final int major = Integer.parseInt(s);
066: return major >= 5;
067: } catch (NumberFormatException e) {
068: Log.error(e);
069: return false;
070: }
071: }
072:
073: public static final boolean isPlatformWindowsNT4() {
074: if (!isPlatformWindows)
075: return false;
076: if (osName.indexOf("Windows NT") < 0)
077: return false;
078: final String version = System.getProperty("os.version");
079: int index = version.indexOf('.');
080: final String s = index >= 0 ? version.substring(0, index)
081: : version;
082: try {
083: final int major = Integer.parseInt(s);
084: return major >= 4;
085: } catch (NumberFormatException e) {
086: Log.error(e);
087: return false;
088: }
089: }
090:
091: public static final boolean isJava13() {
092: return isJava13;
093: }
094:
095: public static final boolean isJava14() {
096: return isJava14;
097: }
098:
099: public static final boolean isJava140() {
100: return isJava140;
101: }
102: }
|