PageRenderTime 1185ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/izpack-src/tags/switch-gpl-to-asl/src/lib/com/izforge/izpack/util/OsVersion.java

https://github.com/jponge/izpack-full-svn-history-copy
Java | 89 lines | 22 code | 13 blank | 54 comment | 6 complexity | f3bd8f55def163cd8ae00f1cf726fbd3 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. *
  27. * @author hani
  28. */
  29. public final class OsVersion
  30. {
  31. public static final String OS_NAME = System.getProperty("os.name");
  32. private static boolean startsWith(String str, String prefix)
  33. {
  34. return str != null && str.startsWith(prefix);
  35. }
  36. private static boolean startsWithIgnoreCase(String str, String prefix)
  37. {
  38. return str != null && str.toUpperCase().startsWith(prefix.toUpperCase());
  39. }
  40. /**
  41. * True if this is FreeBSD.
  42. */
  43. public static final boolean IS_FREEBSD = startsWithIgnoreCase(OS_NAME, "FreeBSD");
  44. /**
  45. * True if this is Linux.
  46. */
  47. public static final boolean IS_LINUX = startsWithIgnoreCase(OS_NAME, "Linux");
  48. /**
  49. * True if this is HP-UX.
  50. */
  51. public static final boolean IS_HPUX = startsWithIgnoreCase(OS_NAME, "HP-UX");
  52. /**
  53. * True if this is AIX.
  54. */
  55. public static final boolean IS_AIX = startsWithIgnoreCase(OS_NAME, "AIX");
  56. /**
  57. * True if this is SunOS.
  58. */
  59. public static final boolean IS_SUNOS = startsWithIgnoreCase(OS_NAME, "SunOS");
  60. /**
  61. * True if this is OS/2.
  62. */
  63. public static final boolean IS_OS2 = startsWith(OS_NAME, "OS/2");
  64. /**
  65. * True if this is the Mac OS X.
  66. */
  67. public static final boolean IS_OSX = startsWith(OS_NAME, "Mac") && OS_NAME.endsWith("X");
  68. /**
  69. * True if this is Windows.
  70. */
  71. public static final boolean IS_WINDOWS = startsWith(OS_NAME, "Windows");
  72. /**
  73. * True if this is some variant of Unix (OSX, Linux, Solaris, FreeBSD, etc).
  74. */
  75. public static final boolean IS_UNIX = !IS_OS2 && !IS_WINDOWS;
  76. }