001
014
015 package com.liferay.portal.kernel.util;
016
017 import java.io.File;
018
019
022 public class OSDetector {
023
024 public static String getBitmode() {
025 if (_bitMode == null) {
026 _bitMode = System.getProperty("sun.arch.data.model");
027
028 if (Validator.isNull(_bitMode)) {
029 _bitMode = System.getProperty("com.ibm.vm.bitmode");
030 }
031
032 if (Validator.isNull(_bitMode)) {
033 String arch = System.getProperty("os.arch");
034
035 arch = arch.toLowerCase();
036
037 if (arch.equals("amd64") || arch.equals("x86_64")) {
038 _bitMode = "64";
039 }
040 else if (arch.equals("i386") || arch.equals("i686") ||
041 arch.equals("x86")) {
042
043 _bitMode = "32";
044 }
045 }
046 }
047
048 return _bitMode;
049 }
050
051 public static boolean isAIX() {
052 if (_aix != null) {
053 return _aix.booleanValue();
054 }
055
056 String osName = System.getProperty("os.name");
057
058 osName = osName.toLowerCase();
059
060 if (osName.equals("aix")) {
061 _aix = Boolean.TRUE;
062 }
063 else {
064 _aix = Boolean.FALSE;
065 }
066
067 return _aix.booleanValue();
068 }
069
070 public static boolean isApple() {
071 if (_apple != null) {
072 return _apple.booleanValue();
073 }
074
075 String osName = System.getProperty("os.name");
076
077 osName = osName.toLowerCase();
078
079 if (osName.contains("darwin") || osName.contains("mac")) {
080 _apple = Boolean.TRUE;
081 }
082 else {
083 _apple = Boolean.FALSE;
084 }
085
086 return _apple.booleanValue();
087 }
088
089 public static boolean isLinux() {
090 if (_linux != null) {
091 return _linux.booleanValue();
092 }
093
094 String osName = System.getProperty("os.name");
095
096 osName = osName.toLowerCase();
097
098 if (osName.contains("linux")) {
099 _linux = Boolean.TRUE;
100 }
101 else {
102 _linux = Boolean.FALSE;
103 }
104
105 return _linux.booleanValue();
106 }
107
108 public static boolean isUnix() {
109 if (_unix != null) {
110 return _unix.booleanValue();
111 }
112
113 if (File.pathSeparator.equals(StringPool.COLON)) {
114 _unix = Boolean.TRUE;
115 }
116 else {
117 _unix = Boolean.FALSE;
118 }
119
120 return _unix.booleanValue();
121 }
122
123 public static boolean isWindows() {
124 if (_windows != null) {
125 return _windows.booleanValue();
126 }
127
128 if (File.pathSeparator.equals(StringPool.SEMICOLON)) {
129 _windows = Boolean.TRUE;
130 }
131 else {
132 _windows = Boolean.FALSE;
133 }
134
135 return _windows.booleanValue();
136 }
137
138 private static Boolean _aix;
139 private static Boolean _apple;
140 private static String _bitMode;
141 private static Boolean _linux;
142 private static Boolean _unix;
143 private static Boolean _windows;
144
145 }