PageRenderTime 55ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/projects/jext-5.0/src/lib/org/gjt/sp/jedit/OperatingSystem.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 163 lines | 84 code | 16 blank | 63 comment | 28 complexity | ed6e925b8b0e44b8075e7dd7e8066d17 MD5 | raw file
  1. /*
  2. * OperatingSystem.java - OS detection
  3. * Copyright (C) 2002 Slava Pestov
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. package org.gjt.sp.jedit;
  20. import javax.swing.UIManager;
  21. import java.io.File;
  22. /**
  23. * Contains operating system detection routines.
  24. * @author Slava Pestov
  25. * @version $Id: OperatingSystem.java,v 1.1 2002/08/11 01:18:37 gfx Exp $
  26. * @since jEdit 4.0pre4
  27. */
  28. public class OperatingSystem
  29. {
  30. //{{{ isDOSDerived() method
  31. /**
  32. * Returns if we're running Windows 95/98/ME/NT/2000/XP, or OS/2.
  33. */
  34. public static final boolean isDOSDerived()
  35. {
  36. return isWindows() || isOS2();
  37. } //}}}
  38. //{{{ isWindows() method
  39. /**
  40. * Returns if we're running Windows 95/98/ME/NT/2000/XP.
  41. */
  42. public static final boolean isWindows()
  43. {
  44. return os == WINDOWS_9x || os == WINDOWS_NT;
  45. } //}}}
  46. //{{{ isWindows9x() method
  47. /**
  48. * Returns if we're running Windows 95/98/ME.
  49. */
  50. public static final boolean isWindows9x()
  51. {
  52. return os == WINDOWS_9x;
  53. } //}}}
  54. //{{{ isWindowsNT() method
  55. /**
  56. * Returns if we're running Windows NT/2000/XP.
  57. */
  58. public static final boolean isWindowsNT()
  59. {
  60. return os == WINDOWS_NT;
  61. } //}}}
  62. //{{{ isOS2() method
  63. /**
  64. * Returns if we're running OS/2.
  65. */
  66. public static final boolean isOS2()
  67. {
  68. return os == OS2;
  69. } //}}}
  70. //{{{ isUnix() method
  71. /**
  72. * Returns if we're running Unix (this includes MacOS X).
  73. */
  74. public static final boolean isUnix()
  75. {
  76. return os == UNIX || os == MAC_OS_X;
  77. } //}}}
  78. //{{{ isMacOS() method
  79. /**
  80. * Returns if we're running MacOS X.
  81. */
  82. public static final boolean isMacOS()
  83. {
  84. return os == MAC_OS_X;
  85. } //}}}
  86. //{{{ isMacOSLF() method
  87. /**
  88. * Returns if we're running MacOS X and using the native L&F.
  89. */
  90. public static final boolean isMacOSLF()
  91. {
  92. return (isMacOS() && UIManager.getLookAndFeel().isNativeLookAndFeel());
  93. } //}}}
  94. //{{{ isJava14() method
  95. /**
  96. * Returns if Java 2 version 1.4 is in use.
  97. */
  98. public static final boolean hasJava14()
  99. {
  100. return java14;
  101. } //}}}
  102. //{{{ Private members
  103. private static final int UNIX = 0x31337;
  104. private static final int WINDOWS_9x = 0x640;
  105. private static final int WINDOWS_NT = 0x666;
  106. private static final int OS2 = 0xDEAD;
  107. private static final int MAC_OS_X = 0xABC;
  108. private static final int UNKNOWN = 0xBAD;
  109. private static int os;
  110. private static boolean java14;
  111. //{{{ Class initializer
  112. static
  113. {
  114. if(System.getProperty("mrj.version") != null)
  115. {
  116. os = MAC_OS_X;
  117. }
  118. else
  119. {
  120. String osName = System.getProperty("os.name");
  121. if(osName.indexOf("Windows 9") != -1
  122. || osName.indexOf("Windows ME") != -1)
  123. {
  124. os = WINDOWS_9x;
  125. }
  126. else if(osName.indexOf("Windows") != -1)
  127. {
  128. os = WINDOWS_NT;
  129. }
  130. else if(osName.indexOf("OS/2") != -1)
  131. {
  132. os = OS2;
  133. }
  134. else if(File.separatorChar == '/')
  135. {
  136. os = UNIX;
  137. }
  138. else
  139. {
  140. os = UNKNOWN;
  141. }
  142. }
  143. if(System.getProperty("java.version").compareTo("1.4") >= 0)
  144. java14 = true;
  145. } //}}}
  146. //}}}
  147. }