PageRenderTime 1749ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/izpack-src/tags/release-candidate-3-7-0-RC2/src/lib/com/izforge/izpack/util/OsVersion.java

https://github.com/jponge/izpack-full-svn-history-copy
Java | 87 lines | 22 code | 12 blank | 53 comment | 6 complexity | 2103095678fc3c1b4dd5dd5f2d2b3db5 MD5 | raw file
  1. /*
  2. * $Id$
  3. * IzPack
  4. * Copyright (C) 2004 Hani Suleiman
  5. *
  6. * File : OsVersion.java
  7. * Description : Helper for OS version handling.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. */
  23. package com.izforge.izpack.util;
  24. /**
  25. * Date: Nov 9, 2004 Time: 8:53:22 PM
  26. * @author hani
  27. */
  28. public final class OsVersion
  29. {
  30. public static final String OS_NAME = System.getProperty("os.name");
  31. private static boolean startsWith(String str, String prefix)
  32. {
  33. return str != null && str.startsWith(prefix);
  34. }
  35. private static boolean startsWithIgnoreCase(String str, String prefix)
  36. {
  37. return str != null && str.toUpperCase().startsWith(prefix.toUpperCase());
  38. }
  39. /**
  40. * True if this is FreeBSD.
  41. */
  42. public static final boolean IS_FREEBSD = startsWithIgnoreCase(OS_NAME, "FreeBSD");
  43. /**
  44. * True if this is Linux.
  45. */
  46. public static final boolean IS_LINUX = startsWithIgnoreCase(OS_NAME, "Linux");
  47. /**
  48. * True if this is HP-UX.
  49. */
  50. public static final boolean IS_HPUX = startsWithIgnoreCase(OS_NAME, "HP-UX");
  51. /**
  52. * True if this is AIX.
  53. */
  54. public static final boolean IS_AIX = startsWithIgnoreCase(OS_NAME, "AIX");
  55. /**
  56. * True if this is SunOS.
  57. */
  58. public static final boolean IS_SUNOS = startsWithIgnoreCase(OS_NAME, "SunOS");
  59. /**
  60. * True if this is OS/2.
  61. */
  62. public static final boolean IS_OS2 = startsWith(OS_NAME, "OS/2");
  63. /**
  64. * True if this is the Mac OS X.
  65. */
  66. public static final boolean IS_OSX = startsWith(OS_NAME, "Mac") && OS_NAME.endsWith("X");
  67. /**
  68. * True if this is Windows.
  69. */
  70. public static final boolean IS_WINDOWS = startsWith(OS_NAME, "Windows");
  71. /**
  72. * True if this is some variant of Unix (OSX, Linux, Solaris, FreeBSD, etc).
  73. */
  74. public static final boolean IS_UNIX = !IS_OS2 && !IS_WINDOWS;
  75. }