KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > util > Platform


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.util;
8
9
10 /**
11  * Description of the Class
12  *
13  * @author Laurent Etiemble
14  * @version $Revision: 1.2 $
15  */

16 public class Platform
17 {
18    /** Description of the Field */
19    private static String JavaDoc JAVA_VERSION;
20    /** Description of the Field */
21    public final static boolean IS_JAVA_1_1 = Platform.getJavaVersionMatches(Platform.JAVA_1_1);
22    /** Description of the Field */
23    public final static boolean IS_JAVA_1_2 = Platform.getJavaVersionMatches(Platform.JAVA_1_2);
24    /** Description of the Field */
25    public final static boolean IS_JAVA_1_3 = Platform.getJavaVersionMatches(Platform.JAVA_1_3);
26    /** Description of the Field */
27    public final static boolean IS_JAVA_1_4 = Platform.getJavaVersionMatches(Platform.JAVA_1_4);
28    /** Description of the Field */
29    public final static boolean IS_JAVA_1_5 = Platform.getJavaVersionMatches(Platform.JAVA_1_5);
30    /** Description of the Field */
31    public final static String JavaDoc JAVA_1_1 = "1.1";
32    /** Description of the Field */
33    public final static String JavaDoc JAVA_1_2 = "1.2";
34    /** Description of the Field */
35    public final static String JavaDoc JAVA_1_3 = "1.3";
36    /** Description of the Field */
37    public final static String JavaDoc JAVA_1_4 = "1.4";
38    /** Description of the Field */
39    public final static String JavaDoc JAVA_1_5 = "1.5";
40
41
42    /** Avoid instantiation */
43    private Platform() { }
44
45
46    /**
47     * Gets the javaVersion attribute of the Platform class
48     *
49     * @return The javaVersion value
50     */

51    public static String JavaDoc getJavaVersion()
52    {
53       if (JAVA_VERSION == null)
54       {
55          JAVA_VERSION = System.getProperty("java.version");
56       }
57       return JAVA_VERSION;
58    }
59
60
61    /**
62     * Gets the javaVersionCompatible attribute of the Platform class
63     *
64     * @param version Description of the Parameter
65     * @return The javaVersionCompatible value
66     */

67    public static boolean isJavaVersionCompatible(String JavaDoc version)
68    {
69       if (getJavaVersion() == null)
70       {
71          return false;
72       }
73       return (JAVA_VERSION.compareTo(version) >= 0);
74    }
75
76
77    /**
78     * Gets the javaVersionMatches attribute of the Platform class
79     *
80     * @param versionPrefix Description of the Parameter
81     * @return The javaVersionMatches value
82     */

83    private static boolean getJavaVersionMatches(String JavaDoc versionPrefix)
84    {
85       if (getJavaVersion() == null)
86       {
87          return false;
88       }
89       return JAVA_VERSION.startsWith(versionPrefix);
90    }
91 }
92
Popular Tags