Source Code Cross Referenced for Platform.java in  » Testing » abbot-1.0.1 » abbot » 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 » Testing » abbot 1.0.1 » abbot 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package abbot;
002:
003:        import java.util.StringTokenizer;
004:
005:        /** Simple utility to figure out what platform we're on, what java version
006:         * we're running.
007:         */
008:
009:        public class Platform {
010:
011:            public static final int JAVA_1_0 = 0x1000;
012:            public static final int JAVA_1_1 = 0x1100;
013:            public static final int JAVA_1_2 = 0x1200;
014:            public static final int JAVA_1_3 = 0x1300;
015:            public static final int JAVA_1_4 = 0x1400;
016:            public static final int JAVA_1_5 = 0x1500;
017:            public static final int JAVA_1_6 = 0x1600;
018:
019:            public static final String OS_NAME;
020:            public static final String JAVA_VERSION_STRING;
021:            public static final int JAVA_VERSION;
022:
023:            static {
024:                OS_NAME = System.getProperty("os.name");
025:                JAVA_VERSION_STRING = System.getProperty("java.version");
026:                JAVA_VERSION = parse(JAVA_VERSION_STRING);
027:            }
028:
029:            private static boolean isWindows = OS_NAME.startsWith("Windows");
030:            private static boolean isWindows9X = isWindows
031:                    && (OS_NAME.indexOf("95") != -1
032:                            || OS_NAME.indexOf("98") != -1 || OS_NAME
033:                            .indexOf("ME") != -1);
034:            private static boolean isWindowsXP = isWindows
035:                    && OS_NAME.indexOf("XP") != -1;
036:            private static boolean isMac = System.getProperty("mrj.version") != null;
037:            private static boolean isOSX = isMac
038:                    && OS_NAME.indexOf("OS X") != -1;
039:            private static boolean isSunOS = (OS_NAME.startsWith("SunOS") || OS_NAME
040:                    .startsWith("Solaris"));
041:            private static boolean isHPUX = OS_NAME.equals("HP-UX");
042:            private static boolean isLinux = OS_NAME.equals("Linux");
043:
044:            /** No instantiations. */
045:            private Platform() {
046:            }
047:
048:            private static String strip(String number) {
049:                while (number.startsWith("0") && number.length() > 1)
050:                    number = number.substring(1);
051:                return number;
052:            }
053:
054:            static int parse(String vs) {
055:                int version = 0;
056:                try {
057:                    StringTokenizer st = new StringTokenizer(vs, "._");
058:                    version = Integer.parseInt(strip(st.nextToken())) * 0x1000;
059:                    version += Integer.parseInt(strip(st.nextToken())) * 0x100;
060:                    version += Integer.parseInt(strip(st.nextToken())) * 0x10;
061:                    version += Integer.parseInt(strip(st.nextToken()));
062:                } catch (NumberFormatException nfe) {
063:                } catch (java.util.NoSuchElementException nse) {
064:                }
065:                return version;
066:            }
067:
068:            // FIXME this isn't entirely correct, maybe should look for a motif class
069:            // instead. 
070:            public static boolean isX11() {
071:                return !isOSX && !isWindows;
072:            }
073:
074:            public static boolean isWindows() {
075:                return isWindows;
076:            }
077:
078:            public static boolean isWindows9X() {
079:                return isWindows9X;
080:            }
081:
082:            public static boolean isWindowsXP() {
083:                return isWindowsXP;
084:            }
085:
086:            public static boolean isMacintosh() {
087:                return isMac;
088:            }
089:
090:            public static boolean isOSX() {
091:                return isOSX;
092:            }
093:
094:            public static boolean isSolaris() {
095:                return isSunOS;
096:            }
097:
098:            public static boolean isHPUX() {
099:                return isHPUX;
100:            }
101:
102:            public static boolean isLinux() {
103:                return isLinux;
104:            }
105:
106:            public static void main(String[] args) {
107:                System.out.println("Java version is " + JAVA_VERSION_STRING);
108:                System.out.println("Version number is "
109:                        + Integer.toHexString(JAVA_VERSION));
110:                System.out.println("os.name=" + OS_NAME);
111:            }
112:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.