1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.kernel.servlet;
24  
25  import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
26  
27  import javax.servlet.http.HttpServletRequest;
28  
29  /**
30   * <a href="BrowserSnifferUtil.java.html"><b><i>View Source</i></b></a>
31   *
32   * See http://www.zytrax.com/tech/web/browser_ids.htm for examples.
33   *
34   * @author Brian Wing Shun Chan
35   *
36   */
37  public class BrowserSnifferUtil {
38  
39      public static boolean acceptsGzip(HttpServletRequest request) {
40          return getBrowserSniffer().acceptsGzip(request);
41      }
42  
43      public static BrowserSniffer getBrowserSniffer() {
44          return _getUtil()._browserSniffer;
45      }
46  
47      public static boolean is_ie(HttpServletRequest request) {
48          return getBrowserSniffer().is_ie(request);
49      }
50  
51      public static boolean is_ie_4(HttpServletRequest request) {
52          return getBrowserSniffer().is_ie_4(request);
53      }
54  
55      public static boolean is_ie_5(HttpServletRequest request) {
56          return getBrowserSniffer().is_ie_5(request);
57      }
58  
59      public static boolean is_ie_5_5(HttpServletRequest request) {
60          return getBrowserSniffer().is_ie_5_5(request);
61      }
62  
63      public static boolean is_ie_5_5_up(HttpServletRequest request) {
64          return getBrowserSniffer().is_ie_5_5_up(request);
65      }
66  
67      public static boolean is_ie_6(HttpServletRequest request) {
68          return getBrowserSniffer().is_ie_6(request);
69      }
70  
71      public static boolean is_ie_7(HttpServletRequest request) {
72          return getBrowserSniffer().is_ie_7(request);
73      }
74  
75      public static boolean is_linux(HttpServletRequest request) {
76          return getBrowserSniffer().is_linux(request);
77      }
78  
79      public static boolean is_mozilla(HttpServletRequest request) {
80          return getBrowserSniffer().is_mozilla(request);
81      }
82  
83      public static boolean is_mozilla_1_3_up(HttpServletRequest request) {
84          return getBrowserSniffer().is_mozilla_1_3_up(request);
85      }
86  
87      public static boolean is_ns_4(HttpServletRequest request) {
88          return getBrowserSniffer().is_ns_4(request);
89      }
90  
91      public static boolean is_rtf(HttpServletRequest request) {
92          return getBrowserSniffer().is_rtf(request);
93      }
94  
95      public static boolean is_safari(HttpServletRequest request) {
96          return getBrowserSniffer().is_safari(request);
97      }
98  
99      public static boolean is_safari_3(HttpServletRequest request) {
100         return getBrowserSniffer().is_safari_3(request);
101     }
102 
103     public static boolean is_safari_mobile(HttpServletRequest request) {
104         return getBrowserSniffer().is_safari_mobile(request);
105     }
106 
107     public static boolean is_wap(HttpServletRequest request) {
108         return getBrowserSniffer().is_wap(request);
109     }
110 
111     public static boolean is_wap_xhtml(HttpServletRequest request) {
112         return getBrowserSniffer().is_wap_xhtml(request);
113     }
114 
115     public static boolean is_wml(HttpServletRequest request) {
116         return getBrowserSniffer().is_wml(request);
117     }
118 
119     public void setBrowserSniffer(BrowserSniffer browserSniffer) {
120         _browserSniffer = browserSniffer;
121     }
122 
123     private static BrowserSnifferUtil _getUtil() {
124         if (_util == null) {
125             _util = (BrowserSnifferUtil)PortalBeanLocatorUtil.locate(_UTIL);
126         }
127 
128         return _util;
129     }
130 
131     private static final String _UTIL = BrowserSnifferUtil.class.getName();
132 
133     private static BrowserSnifferUtil _util;
134 
135     private BrowserSniffer _browserSniffer;
136 
137 }