All Downloads are FREE. Search and download functionalities are using the official Maven repository.

browserl.ist.Agent Maven / Gradle / Ivy

The newest version!
package browserl.ist;

/**
 * @author Kent Yeh
 */
public enum Agent {

    IE("ie", "Internet Explorer"), EXPLORER("ie", "Internet Explorer"),
    EXPLORERMOBILE("ie_mob", "IE Mobile"), EDGE("edge", "Edge"),
    FIREFOX("firefox", "Firefox"), FF("firefox", "Firefox"),
    FX("firefox", "Firefox"), FIREFOXANDROID("and_ff", "Firefox for Android"),
    CHROME("chrome", "Chrome"), CHROMEANDROID("and_chr", "Chrome for Android"),
    OPERA("opera", "Opera"), OPERAMINI("op_mini", "Opera Mini"), OPERAMOBILE("op_mob", "Opera Mobile"),
    SAFARI("safari", "Safari"), IOS("ios_saf", "iOS Safari"),
    ANDROID("android", "Android Browser"), UCANDROID("and_uc", "UC Browser for Android"),
    QQBROWSER("and_qq", "QQ Browser"), QQ("and_qq", "QQ Browser"),
    BB("bb", "Blackberry Browser"), BLACKBERRY("bb", "Blackberry Browser"),
    SAMSUNG("samsung", "Samsung Internet"), SS("samsung", "Samsung Internet");

    private final String browser;
    private final String fullName;

    private Agent(String browser, String fullName) {
        this.browser = browser;
        this.fullName = fullName;
    }

    public boolean isBrowser(Agent agent) {
        return this.equals(agent);
    }

    public boolean isBrowser(String browser) {
        return this.name().equalsIgnoreCase(browser) || this.browser.equalsIgnoreCase(browser);
    }

    public String getSymbol() {
        return browser;
    }

    @Deprecated
    public String ver(Number version) {
        return this.browser + " " + version;
    }

    public String ver(String version) {
        return this.browser + " " + version;
    }

    public static Agent eval(String name) {
        try {
            return Agent.valueOf(name.toUpperCase());
        } catch (IllegalArgumentException ex) {
            name = name.split("\\s+")[0].toLowerCase();
            for (Agent a : Agent.values()) {
                if (a.isBrowser(name)) {
                    return a;
                }
            }
            return null;
        }
    }

    @Override
    public String toString() {
        return fullName;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy