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                            String osName = System.getProperty("os.name").toLowerCase();
027    
028                            if (osName.equals("aix")) {
029                                    _aix = Boolean.TRUE;
030                            }
031                            else {
032                                    _aix = Boolean.FALSE;
033                            }
034                    }
035    
036                    return _aix.booleanValue();
037            }
038    
039            public static boolean isApple() {
040                    if (_apple == null) {
041                            String osName = System.getProperty("os.name").toLowerCase();
042    
043                            if (osName.contains("mac")) {
044                                    _apple = Boolean.TRUE;
045                            }
046                            else {
047                                    _apple = Boolean.FALSE;
048                            }
049                    }
050    
051                    return _apple.booleanValue();
052            }
053    
054            public static boolean isUnix() {
055                    if (_unix == null) {
056                            if (File.pathSeparator.equals(StringPool.COLON)) {
057                                    _unix = Boolean.TRUE;
058                            }
059                            else {
060                                    _unix = Boolean.FALSE;
061                            }
062                    }
063    
064                    return _unix.booleanValue();
065            }
066    
067            public static boolean isWindows() {
068                    if (_windows == null) {
069                            if (File.pathSeparator.equals(StringPool.SEMICOLON)) {
070                                    _windows = Boolean.TRUE;
071                            }
072                            else {
073                                    _windows = Boolean.FALSE;
074                            }
075                    }
076    
077                    return _windows.booleanValue();
078            }
079    
080            private static Boolean _aix;
081            private static Boolean _apple;
082            private static Boolean _unix;
083            private static Boolean _windows;
084    
085    }