001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    }