Source Code Cross Referenced for BrowserProfile.java in  » Swing-Library » Swinglets » com » javelin » swinglets » 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 » Swing Library » Swinglets » com.javelin.swinglets 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright Javelin Software, All rights reserved.
003:         */
004:
005:        package com.javelin.swinglets;
006:
007:        /**
008:         * This class can be used to sniff the browser profile from  
009:         * BrowserProfile prof=BrowserProfile.getProfile(request);
010:         *
011:         * @author Robin Sharp
012:         */
013:
014:        import java.util.*;
015:        import java.text.*;
016:
017:        public class BrowserProfile {
018:            //MIME TYPE
019:            public String mimeType;
020:
021:            //Look and Feel
022:            public boolean isWAP;
023:            public boolean isHTML;
024:            public double jsVer;
025:
026:            // WAP/WML
027:            public boolean isUP;
028:            public boolean isNokia;
029:            public boolean isEricsson;
030:
031:            //HTML BROWSERS
032:            public boolean isNS;
033:            public boolean isNS2;
034:            public boolean isNS3;
035:            public boolean isNS4;
036:            public boolean isNS4UP;
037:            public boolean isNS5;
038:            public boolean isNS5UP;
039:
040:            public boolean isIE;
041:            public boolean isIE3;
042:            public boolean isIE4;
043:            public boolean isIE4UP;
044:            public boolean isIE5;
045:            public boolean isIE5UP;
046:
047:            public boolean isAOL;
048:            public boolean isAOL3;
049:            public boolean isAOL4;
050:
051:            public boolean isOPERA;
052:
053:            public boolean isWEBTV;
054:
055:            public boolean isMAC;
056:            public boolean isMAC68K;
057:            public boolean isMACPPC;
058:
059:            public boolean isWIN;
060:            public boolean isWIN95;
061:            public boolean isWIN98;
062:            public boolean isWINNT;
063:            public boolean isUNIX;
064:
065:            public boolean isSUN;
066:            public boolean isSUN4;
067:            public boolean isSUN5;
068:            public boolean isSUNI86;
069:
070:            public boolean isIRIX;
071:            public boolean isIRIX5;
072:            public boolean isIRIX6;
073:
074:            public boolean isHPUX;
075:            public boolean isHPUX9;
076:            public boolean isHPUX10;
077:
078:            public boolean isAIX;
079:            public boolean isAIX1;
080:            public boolean isAIX2;
081:            public boolean isAIX3;
082:            public boolean isAIX4;
083:
084:            public boolean isOS2;
085:
086:            public boolean isLINUX;
087:            public boolean isSCO;
088:            public boolean isUNIXWARE;
089:
090:            public boolean isMPRAS;
091:            public boolean isRELIANT;
092:            public boolean isDEC;
093:            public boolean isSINIX;
094:            public boolean isFREEBSD;
095:            public boolean isBSD;
096:
097:            public boolean isVMS;
098:
099:            public boolean isMOZ;
100:            public double mozVer;
101:            public int mozVerMajor;
102:
103:            /**
104:             * Get the BrowserProfile from the profile string. If the BrowserProfile
105:             * has already been setup, get it from the hashtable, to save setting it
106:             * up again.
107:             */
108:            public synchronized static BrowserProfile getProfile(
109:                    String userAgent, String mimeType) {
110:                if (profiles.contains(userAgent)) {
111:                    return (BrowserProfile) profiles.get(userAgent);
112:                }
113:
114:                BrowserProfile prof = new BrowserProfile();
115:                prof.setupProfile(userAgent, mimeType);
116:                profiles.put(userAgent, prof);
117:
118:                return prof;
119:            }
120:
121:            private void setupProfile(String name, String mimeType) {
122:                this .mimeType = mimeType;
123:
124:                String agt = name.toLowerCase();
125:
126:                if (agt.startsWith("up.browser")) {
127:                    //UP.Browser/3.1-SH UP.Link/3.2
128:                    isWAP = true;
129:                    isUP = true;
130:                } else if (agt.indexOf("nokia") > -1) {
131:                    //jigsaw/2.0beta2
132:                    isWAP = true;
133:                    isNokia = true;
134:                } else if (agt.indexOf("r320s") > -1) {
135:                    isWAP = true;
136:                    isEricsson = true;
137:                } else {
138:                    isHTML = true;
139:                }
140:
141:                isMOZ = agt.startsWith("mozilla");
142:                mozVer = 0;
143:                if (isMOZ) {
144:                    String mozver = agt.substring(8);
145:
146:                    try {
147:                        Number f = format.parse(mozver);
148:                        mozVer = f.doubleValue();
149:                    } catch (Exception ex) {
150:                        //Fail Silently
151:                    }
152:                }
153:
154:                mozVerMajor = (int) mozVer;
155:
156:                isNS = (agt.indexOf("mozilla") != -1)
157:                        && (agt.indexOf("spoofer") == -1)
158:                        && (agt.indexOf("compatible") == -1)
159:                        && (agt.indexOf("opera") == -1)
160:                        && (agt.indexOf("webtv") == -1);
161:
162:                isNS2 = isNS && mozVerMajor == 2;
163:                isNS3 = isNS && mozVerMajor == 3;
164:                isNS4 = isNS && mozVerMajor == 4;
165:                isNS4UP = isNS && mozVerMajor >= 4;
166:                isNS5 = isNS && mozVerMajor == 5;
167:                isNS5UP = isNS && mozVerMajor >= 5;
168:
169:                isIE = (agt.indexOf("msie") != -1);
170:                isIE3 = isIE && mozVerMajor < 4;
171:                isIE4 = isIE && mozVerMajor == 4
172:                        && (agt.indexOf("msie 5.0") == -1);
173:                isIE4UP = isIE && mozVer >= 4;
174:                isIE5 = isIE && mozVerMajor == 4
175:                        && (agt.indexOf("msie 5.0") != -1);
176:                isIE5UP = isIE && !isIE3 && !isIE4;
177:
178:                isAOL = (agt.indexOf("aol") != -1);
179:                isAOL3 = isAOL && isIE3;
180:                isAOL4 = isAOL && isIE4;
181:
182:                isOPERA = (agt.indexOf("opera") != -1);
183:                isWEBTV = (agt.indexOf("webtv") != -1);
184:
185:                if (isNS2 || isIE3) {
186:                    jsVer = 1.0;
187:                } else if (isNS3 || isOPERA) {
188:                    jsVer = 1.1;
189:                } else if (isNS4 && mozVer <= 4.05 || isIE4) {
190:                    jsVer = 1.2;
191:                } else if (isNS4 && mozVer > 4.05 || isIE5) {
192:                    jsVer = 1.3;
193:                } else if (isNS5) {
194:                    jsVer = 1.4;
195:                } else if (isNS && mozVerMajor > 5) {
196:                    jsVer = 1.4;
197:                } else if (isIE && mozVerMajor > 5) {
198:                    jsVer = 1.3;
199:                } else {
200:                    jsVer = 0.0;
201:                }
202:
203:                isWIN = (agt.indexOf("win") != -1)
204:                        || (agt.indexOf("16bit") != -1);
205:                isWIN95 = (agt.indexOf("win95") != -1)
206:                        || (agt.indexOf("windows 95") != -1);
207:                isWIN98 = (agt.indexOf("win98") != -1)
208:                        || (agt.indexOf("windows 98") != -1);
209:                isWINNT = (agt.indexOf("winnt") != -1)
210:                        || (agt.indexOf("windows nt") != -1);
211:                isOS2 = (agt.indexOf("os/2") != -1)
212:                        || (agt.indexOf("ibm-webexplorer") != -1);
213:                isWIN98 = (agt.indexOf("win98") != -1)
214:                        || (agt.indexOf("windows 98") != -1);
215:
216:                isSUN = (agt.indexOf("sunos") != -1);
217:                isSUN4 = (agt.indexOf("sunos 4") != -1);
218:                isSUN5 = (agt.indexOf("sunos 5") != -1);
219:                isSUNI86 = (isSUN && agt.indexOf("i86") != -1);
220:                isIRIX = (agt.indexOf("irix") != -1);
221:                isIRIX5 = (agt.indexOf("irix 5") != -1);
222:                isIRIX6 = (agt.indexOf("irix 6") != -1)
223:                        || (agt.indexOf("irix6") != -1);
224:                isHPUX = (agt.indexOf("hp-ux") != -1);
225:                isHPUX9 = isHPUX && (agt.indexOf("09.") != -1);
226:                isHPUX10 = isHPUX && (agt.indexOf("10.") != -1);
227:
228:                isAIX = (agt.indexOf("aix") != -1);
229:                isAIX1 = (agt.indexOf("aix 1") != -1);
230:                isAIX2 = (agt.indexOf("aix 2") != -1);
231:                isAIX3 = (agt.indexOf("aix 3") != -1);
232:                isAIX4 = (agt.indexOf("aix 4") != -1);
233:
234:                isLINUX = (agt.indexOf("inux") != -1);
235:
236:                isSCO = (agt.indexOf("sco") != -1)
237:                        || (agt.indexOf("unix_sv") != -1);
238:
239:                isUNIXWARE = (agt.indexOf("unix_system_v") != -1);
240:
241:                isMPRAS = (agt.indexOf("ncr") != -1);
242:
243:                isRELIANT = (agt.indexOf("reliantunix") != -1);
244:
245:                isDEC = (agt.indexOf("dec") != -1)
246:                        || (agt.indexOf("osf1") != -1)
247:                        || (agt.indexOf("dec_alpha") != -1)
248:                        || (agt.indexOf("alphaserver") != -1)
249:                        || (agt.indexOf("ultrix") != -1)
250:                        || (agt.indexOf("alphastation") != -1);
251:
252:                isSINIX = (agt.indexOf("sinix") != -1);
253:                isFREEBSD = (agt.indexOf("freebsd") != -1);
254:                isBSD = (agt.indexOf("bsd") != -1);
255:
256:                isUNIX = (agt.indexOf("x11") != -1) || isSUN || isIRIX
257:                        || isHPUX || isSCO || isUNIXWARE || isMPRAS
258:                        || isRELIANT || isDEC || isSINIX || isAIX || isBSD
259:                        || isFREEBSD;
260:
261:                isVMS = (agt.indexOf("vax") != -1)
262:                        || (agt.indexOf("openvms") != -1);
263:
264:                isMAC = (agt.indexOf("mac") != -1);
265:                isMAC68K = (agt.indexOf("68k") != -1)
266:                        || (agt.indexOf("68000") != -1);
267:                isMACPPC = (agt.indexOf("ppc") != -1)
268:                        || (agt.indexOf("powerpc") != -1);
269:
270:                if ("text/html".equals(mimeType)) {
271:                    isHTML = true;
272:                } else if ("text/vnd.wap.wml".equals(mimeType)) {
273:                    isWAP = true;
274:                }
275:            }
276:
277:            static private Hashtable profiles = new java.util.Hashtable();
278:            static private DecimalFormat format = new DecimalFormat();
279:
280:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.