Source Code Cross Referenced for JavaUtils.java in  » Database-ORM » JPOX » org » jpox » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » JPOX » org.jpox.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************
002:        Copyright (c) 2005 Andy Jefferson and others. All rights reserved.
003:        Licensed under the Apache License, Version 2.0 (the "License");
004:        you may not use this file except in compliance with the License.
005:        You may obtain a copy of the License at
006:
007:            http://www.apache.org/licenses/LICENSE-2.0
008:
009:        Unless required by applicable law or agreed to in writing, software
010:        distributed under the License is distributed on an "AS IS" BASIS,
011:        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012:        See the License for the specific language governing permissions and
013:        limitations under the License. 
014:
015:
016:        Contributors:
017:            ...
018:         **********************************************************************/package org.jpox.util;
019:
020:        import java.util.StringTokenizer;
021:
022:        /**
023:         * Utilities relating to the version of Java in use at runtime.
024:         * @version $Revision: 1.8 $
025:         */
026:        public class JavaUtils {
027:            private static boolean versionInitialised = false;
028:            private static int majorVersion = 1;
029:            private static int minorVersion = 0;
030:            private static int isJRE14 = -1;
031:            private static int isJRE15 = -1;
032:            private static int isJRE16 = -1;
033:
034:            /**
035:             * Accessor for whether the JRE is 1.4 (or above). 
036:             * Checks for the presence of a known 1.4 class.
037:             * @return Whether the JRE is 1.4 or above
038:             */
039:            public static boolean isJRE1_4OrAbove() {
040:                if (isJRE14 == -1) {
041:                    try {
042:                        Class.forName("java.util.Currency");
043:                        isJRE14 = 1;
044:                    } catch (Exception e) {
045:                        isJRE14 = 0;
046:                    }
047:                }
048:                return isJRE14 == 1;
049:            }
050:
051:            /**
052:             * Accessor for whether the JRE is 1.5 (or above).
053:             * Checks for the presence of a known 1.5 class.
054:             * @return Whether the JRE is 1.5 or above
055:             */
056:            public static boolean isJRE1_5OrAbove() {
057:                if (isJRE15 == -1) {
058:                    try {
059:                        Class.forName("java.util.Queue");
060:                        isJRE15 = 1;
061:                    } catch (Exception e) {
062:                        isJRE15 = 0;
063:                    }
064:                }
065:                return isJRE15 == 1;
066:            }
067:
068:            /**
069:             * Accessor for whether the JRE is 1.6 (or above).
070:             * Checks for the presence of a known 1.6 class.
071:             * @return Whether the JRE is 1.6 or above
072:             */
073:            public static boolean isJRE1_6OrAbove() {
074:                if (isJRE16 == -1) {
075:                    try {
076:                        Class.forName("java.util.Deque");
077:                        isJRE16 = 1;
078:                    } catch (Exception e) {
079:                        isJRE16 = 0;
080:                    }
081:                }
082:                return isJRE16 == 1;
083:            }
084:
085:            /**
086:             * Accessor for the major version number of the JRE.
087:             * @return The major version number of the JRE
088:             */
089:            public static int getJREMajorVersion() {
090:                if (!versionInitialised) {
091:                    initialiseJREVersion();
092:                }
093:                return majorVersion;
094:            }
095:
096:            /**
097:             * Accessor for the minor version number of the JRE.
098:             * @return The minor version number of the JRE
099:             */
100:            public static int getJREMinorVersion() {
101:                if (!versionInitialised) {
102:                    initialiseJREVersion();
103:                }
104:                return minorVersion;
105:            }
106:
107:            /**
108:             * Utility to initialise the values of the JRE major/minor version.
109:             * Assumes the "java.version" string is in the form "XX.YY.ZZ".
110:             * Works for SUN JRE's.
111:             */
112:            private static void initialiseJREVersion() {
113:                String version = System.getProperty("java.version");
114:
115:                // Assume that the version string is of the form XX.YY.ZZ (works for SUN JREs)
116:                StringTokenizer tokeniser = new StringTokenizer(version, ".");
117:                String token = tokeniser.nextToken();
118:                try {
119:                    Integer ver = new Integer(token);
120:                    majorVersion = ver.intValue();
121:
122:                    token = tokeniser.nextToken();
123:                    ver = new Integer(token);
124:                    minorVersion = ver.intValue();
125:                } catch (Exception e) {
126:                    // Do nothing
127:                }
128:                versionInitialised = true;
129:            }
130:
131:            /**
132:             * Check if the current version is greater or equals than the argument version.
133:             * @param version the version
134:             * @return true if the runtime version is greater equals than the argument
135:             */
136:            public static boolean isGreaterEqualsThan(String version) {
137:                boolean greaterEquals = false;
138:                StringTokenizer tokeniser = new StringTokenizer(version, ".");
139:                String token = tokeniser.nextToken();
140:                try {
141:                    Integer ver = new Integer(token);
142:                    int majorVersion = ver.intValue();
143:
144:                    token = tokeniser.nextToken();
145:                    ver = new Integer(token);
146:                    int minorVersion = ver.intValue();
147:                    if (getJREMajorVersion() >= majorVersion
148:                            && getJREMinorVersion() >= minorVersion) {
149:                        greaterEquals = true;
150:                    }
151:                } catch (Exception e) {
152:                    // Do nothing
153:                }
154:
155:                return greaterEquals;
156:            }
157:
158:            /**
159:             * Check if the current version is equals than the argument version.
160:             * @param version the version
161:             * @return true if the runtime version is equals than the argument
162:             */
163:            public static boolean isEqualsThan(String version) {
164:                boolean equals = false;
165:                StringTokenizer tokeniser = new StringTokenizer(version, ".");
166:                String token = tokeniser.nextToken();
167:                try {
168:                    Integer ver = new Integer(token);
169:                    int majorVersion = ver.intValue();
170:
171:                    token = tokeniser.nextToken();
172:                    ver = new Integer(token);
173:                    int minorVersion = ver.intValue();
174:                    if (getJREMajorVersion() == majorVersion
175:                            && getJREMinorVersion() == minorVersion) {
176:                        equals = true;
177:                    }
178:                } catch (Exception e) {
179:                    // Do nothing
180:                }
181:
182:                return equals;
183:            }
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.