1 7 package org.ejtools.util; 8 9 10 16 public class Platform 17 { 18 19 private static String JAVA_VERSION; 20 21 public final static boolean IS_JAVA_1_1 = Platform.getJavaVersionMatches(Platform.JAVA_1_1); 22 23 public final static boolean IS_JAVA_1_2 = Platform.getJavaVersionMatches(Platform.JAVA_1_2); 24 25 public final static boolean IS_JAVA_1_3 = Platform.getJavaVersionMatches(Platform.JAVA_1_3); 26 27 public final static boolean IS_JAVA_1_4 = Platform.getJavaVersionMatches(Platform.JAVA_1_4); 28 29 public final static boolean IS_JAVA_1_5 = Platform.getJavaVersionMatches(Platform.JAVA_1_5); 30 31 public final static String JAVA_1_1 = "1.1"; 32 33 public final static String JAVA_1_2 = "1.2"; 34 35 public final static String JAVA_1_3 = "1.3"; 36 37 public final static String JAVA_1_4 = "1.4"; 38 39 public final static String JAVA_1_5 = "1.5"; 40 41 42 43 private Platform() { } 44 45 46 51 public static String getJavaVersion() 52 { 53 if (JAVA_VERSION == null) 54 { 55 JAVA_VERSION = System.getProperty("java.version"); 56 } 57 return JAVA_VERSION; 58 } 59 60 61 67 public static boolean isJavaVersionCompatible(String version) 68 { 69 if (getJavaVersion() == null) 70 { 71 return false; 72 } 73 return (JAVA_VERSION.compareTo(version) >= 0); 74 } 75 76 77 83 private static boolean getJavaVersionMatches(String versionPrefix) 84 { 85 if (getJavaVersion() == null) 86 { 87 return false; 88 } 89 return JAVA_VERSION.startsWith(versionPrefix); 90 } 91 } 92 | Popular Tags |