Source Code Cross Referenced for Library.java in  » Ajax » GWT » org » eclipse » swt » internal » 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 » Ajax » GWT » org.eclipse.swt.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2005 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.swt.internal;
011:
012:        public class Library {
013:
014:            /* SWT Version - Mmmm (M=major, mmm=minor) */
015:
016:            /**
017:             * SWT Major version number (must be >= 0)
018:             */
019:            static int MAJOR_VERSION = 3;
020:
021:            /**
022:             * SWT Minor version number (must be in the range 0..999)
023:             */
024:            static int MINOR_VERSION = 235;
025:
026:            /**
027:             * SWT revision number (must be >= 0)
028:             */
029:            static int REVISION = 0;
030:
031:            /**
032:             * The JAVA and SWT versions
033:             */
034:            public static final int JAVA_VERSION, SWT_VERSION;
035:
036:            static {
037:                JAVA_VERSION = parseVersion(System.getProperty("java.version"));
038:                SWT_VERSION = SWT_VERSION(MAJOR_VERSION, MINOR_VERSION);
039:            }
040:
041:            static int parseVersion(String version) {
042:                if (version == null)
043:                    return 0;
044:                int major = 0, minor = 0, micro = 0;
045:                int length = version.length(), index = 0, start = 0;
046:                while (index < length
047:                        && Character.isDigit(version.charAt(index)))
048:                    index++;
049:                try {
050:                    if (start < length)
051:                        major = Integer.parseInt(version
052:                                .substring(start, index));
053:                } catch (NumberFormatException e) {
054:                }
055:                start = ++index;
056:                while (index < length
057:                        && Character.isDigit(version.charAt(index)))
058:                    index++;
059:                try {
060:                    if (start < length)
061:                        minor = Integer.parseInt(version
062:                                .substring(start, index));
063:                } catch (NumberFormatException e) {
064:                }
065:                start = ++index;
066:                while (index < length
067:                        && Character.isDigit(version.charAt(index)))
068:                    index++;
069:                try {
070:                    if (start < length)
071:                        micro = Integer.parseInt(version
072:                                .substring(start, index));
073:                } catch (NumberFormatException e) {
074:                }
075:                return JAVA_VERSION(major, minor, micro);
076:            }
077:
078:            /**
079:             * Returns the Java version number as an integer.
080:             * 
081:             * @param major
082:             * @param minor
083:             * @param micro
084:             * @return the version
085:             */
086:            public static int JAVA_VERSION(int major, int minor, int micro) {
087:                return (major << 16) + (minor << 8) + micro;
088:            }
089:
090:            /**
091:             * Returns the SWT version number as an integer.
092:             * 
093:             * @param major
094:             * @param minor
095:             * @return the version
096:             */
097:            public static int SWT_VERSION(int major, int minor) {
098:                return major * 1000 + minor;
099:            }
100:
101:            /**
102:             * Loads the shared library that matches the version of the
103:             * Java code which is currently running.  SWT shared libraries
104:             * follow an encoding scheme where the major, minor and revision
105:             * numbers are embedded in the library name and this along with
106:             * <code>name</code> is used to load the library.  If this fails,
107:             * <code>name</code> is used in another attempt to load the library,
108:             * this time ignoring the SWT version encoding scheme.
109:             *
110:             * @param name the name of the library to load
111:             */
112:            public static void loadLibrary(String name) {
113:                /*
114:                 * Include platform name to support different windowing systems
115:                 * on same operating system.
116:                 */
117:                String platform = Platform.PLATFORM;
118:
119:                /*
120:                 * Get version qualifier.
121:                 */
122:                String version = System.getProperty("swt.version"); //$NON-NLS-1$
123:                if (version == null) {
124:                    version = "" + MAJOR_VERSION; //$NON-NLS-1$
125:                    /* Force 3 digits in minor version number */
126:                    if (MINOR_VERSION < 10) {
127:                        version += "00"; //$NON-NLS-1$
128:                    } else {
129:                        if (MINOR_VERSION < 100)
130:                            version += "0"; //$NON-NLS-1$
131:                    }
132:                    version += MINOR_VERSION;
133:                    /* No "r" until first revision */
134:                    if (REVISION > 0)
135:                        version += "r" + REVISION; //$NON-NLS-1$
136:                }
137:
138:                /*
139:                 * GOOGLE: Since we're bundling our own version of SWT, we need to be
140:                 * able to tell SWT where its dynamic libraries live.  Otherwise we'd
141:                 * have to force our users to always specify a -Djava.library.path
142:                 * on the command line.
143:                 */
144:                String swtLibraryPath = System.getProperty("swt.library.path");
145:                try {
146:                    String newName = name + "-" + platform + "-" + version; //$NON-NLS-1$ //$NON-NLS-2$
147:                    if (swtLibraryPath != null)
148:                        System.load(swtLibraryPath
149:                                + System.mapLibraryName(newName));
150:                    else
151:                        System.loadLibrary(newName);
152:                    return;
153:                } catch (UnsatisfiedLinkError e1) {
154:                    try {
155:                        String newName = name + "-" + platform; //$NON-NLS-1$
156:                        if (swtLibraryPath != null)
157:                            System.load(swtLibraryPath
158:                                    + System.mapLibraryName(newName));
159:                        else
160:                            System.loadLibrary(newName);
161:                        return;
162:                    } catch (UnsatisfiedLinkError e2) {
163:                        throw e1;
164:                    }
165:                }
166:            }
167:
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.