Get Browser Type tool class

Source: Internet
Author: User
Get Browser Type tool class
Import Java.util.regex.Matcher;

Import Java.util.regex.Pattern; /** * @author Created by Tan Jian on 2018/4/16 0016. Monday.
 16:49. *©all Rights Reserved. * <p> * <p> * Browser Tool class/public class Browserutils {/** * * * @param requestuseragent = Reque St.getheader ("User-agent") * @return Browser Type Enumeration */public static Browser Getbrowser (String Requestuseragen
        T) {if (Distinguishagent (Requestuseragent, IE11)) {return browser.ie11;}
        if (Distinguishagent (Requestuseragent, IE10)) {return browser.ie10;}
        if (Distinguishagent (Requestuseragent, IE9)) {return BROWSER.IE9;}
        if (Distinguishagent (Requestuseragent, IE8)) {return BROWSER.IE8;}
        if (Distinguishagent (Requestuseragent, IE7)) {return browser.ie7;}
        if (Distinguishagent (Requestuseragent, IE6)) {return browser.ie6;}
        if (Distinguishagent (Requestuseragent, Max_thon)) {return browser.max_thon;} if (Distinguishagent (RequestuseragenT, QQ)) {return browser.qq;}
        if (Distinguishagent (Requestuseragent, GREEN)) {return browser.green;}
        if (Distinguishagent (Requestuseragent, SE360)) {return browser.se360;}
        if (Distinguishagent (Requestuseragent, Fire_fox)) {return browser.fire_fox;}
        if (Distinguishagent (Requestuseragent, OPERA)) {return browser.opera;}
        if (Distinguishagent (Requestuseragent, CHROME)) {return browser.chrome;}
        if (Distinguishagent (Requestuseragent, SAFARI)) {return Browser.safari;}
        if (Distinguishagent (Requestuseragent, CAMINO)) {return Browser.camino;}

        if (Distinguishagent (Requestuseragent, GECKO)) {return Browser.gecko;}
    return browser.other; } private static Boolean distinguishagent (String requestuseragent, string agent) {Pattern p = Pattern.compi
        Le (agent, pattern.multiline);
        Matcher m = P.matcher (requestuseragent);
    return M.find (); Private final static String IE11 = "rv:11.0 ", IE10 =" MSIE 10.0 ", IE9 =" Msie 9.0 ", IE8 =" MSIE 8.0 ", IE7 =" M SIE 7.0 ", IE6 =" MSIE 6.0 ", Max_thon =" Maxthon ", QQ =" Qqbrowser ", GREEN
            = "Greenbrowser", SE360 = "360SE", Fire_fox = "Firefox", opera = "Opera",
            Chrome = "Chrome", Safari = "Safari", CAMINO = "CAMINO", GECKO = "GECKO",


    others = "other"; Private enum Browser {IE6 (""), IE7 (""), IE8 (""), IE9 (""), IE10 (""), IE11
        (""), Fire_fox ("Firefox browser"), Max_thon ("Surfing Browser"), QQ ("QQ browser"), GREEN ("Greenbrowser browser"), SE360 ("360 Secure Browser"), others ("other browsers"), Safari ("Apple SAFARI Browser"), CHROME ("Google browser"), Opera ("Opera Browse

        "), CAMINO (" MAC OS x CAMINO Browser "), GECKO (" browser developed based on GECKO engine ");

        Private String describe; BrowseR (String describe) {this.describe = describe;
 }
    }


}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.