View Javadoc

1   /*
2    *  XNap Commons
3    *
4    *  Copyright (C) 2005  Steffen Pingel
5    *
6    *  This library is free software; you can redistribute it and/or
7    *  modify it under the terms of the GNU Lesser General Public
8    *  License as published by the Free Software Foundation; either
9    *  version 2.1 of the License, or (at your option) any later version.
10   *
11   *  This library is distributed in the hope that it will be useful,
12   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   *  Lesser General Public License for more details.
15   *
16   *  You should have received a copy of the GNU Lesser General Public
17   *  License along with this library; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19   */
20  package org.xnap.commons.util;
21  
22  /***
23   * Provides static variables that describe properties of the underlying 
24   * platform and runtime environment. Sometimes it is necessary to work 
25   * around certain differences between platforms or bugs of a specific JDK
26   * release. 
27   *  
28   * @author Steffen Pingel
29   */
30  public class SystemHelper {
31  	
32      /***
33       * True, if is system is Apple Mac OS X; false, otherwise.
34       */
35      public static final boolean IS_MACOSX;
36  
37      /***
38       * True, if system is Microsoft Windows; false, otherwise.
39       */
40      public static final boolean IS_WINDOWS;
41      
42      /***
43       * True, if system is Microsoft Windows XP; false, otherwise.
44       */
45      public static final boolean IS_WINDOWS_XP;    
46  
47      /***
48       * True, if Java version is higher or equal than 1.6.0.
49       */
50      public static final boolean IS_JAVA6_OR_HIGHER;
51  
52      static {
53  		String ver = System.getProperty("java.version", "");
54  		IS_JAVA6_OR_HIGHER = (VersionParser.compare(ver, "1.6") >= 0);
55  
56  		String os = System.getProperty("os.name").toLowerCase();
57  		IS_WINDOWS = (os.indexOf("windows") != -1);
58  		IS_WINDOWS_XP = IS_WINDOWS && (os.indexOf("xp") != -1);
59  		IS_MACOSX = (os.indexOf("mac os x") != -1);
60      }
61  
62  }