001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.util;
016    
017    import java.io.File;
018    
019    /**
020     * @author Brian Wing Shun Chan
021     */
022    public class OSDetector {
023    
024            public static boolean isAIX() {
025                    if (_aix != null) {
026                            return _aix.booleanValue();
027                    }
028    
029                    String osName = System.getProperty("os.name").toLowerCase();
030    
031                    if (osName.equals("aix")) {
032                            _aix = Boolean.TRUE;
033                    }
034                    else {
035                            _aix = Boolean.FALSE;
036                    }
037    
038                    return _aix.booleanValue();
039            }
040    
041            public static boolean isApple() {
042                    if (_apple != null) {
043                            return _apple.booleanValue();
044                    }
045    
046                    String osName = System.getProperty("os.name").toLowerCase();
047    
048                    if (osName.contains("mac")) {
049                            _apple = Boolean.TRUE;
050                    }
051                    else {
052                            _apple = Boolean.FALSE;
053                    }
054    
055                    return _apple.booleanValue();
056            }
057    
058            public static boolean isUnix() {
059                    if (_unix != null) {
060                            return _unix.booleanValue();
061                    }
062    
063                    if (File.pathSeparator.equals(StringPool.COLON)) {
064                            _unix = Boolean.TRUE;
065                    }
066                    else {
067                            _unix = Boolean.FALSE;
068                    }
069    
070                    return _unix.booleanValue();
071            }
072    
073            public static boolean isWindows() {
074                    if (_windows != null) {
075                            return _windows.booleanValue();
076                    }
077    
078                    if (File.pathSeparator.equals(StringPool.SEMICOLON)) {
079                            _windows = Boolean.TRUE;
080                    }
081                    else {
082                            _windows = Boolean.FALSE;
083                    }
084    
085                    return _windows.booleanValue();
086            }
087    
088            private static Boolean _aix;
089            private static Boolean _apple;
090            private static Boolean _unix;
091            private static Boolean _windows;
092    
093    }