Created
October 14, 2011 06:02
-
-
Save akr4/1286364 to your computer and use it in GitHub Desktop.
useragentutils example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UserAgent { | |
private nl.bitwalker.useragentutils.UserAgent ua; | |
private UserAgent(nl.bitwalker.useragentutils.UserAgent ua) { | |
this.ua = ua; | |
} | |
public boolean isFirefox7Plus() { | |
if (ua.getBrowser().getGroup() == Browser.FIREFOX) { | |
try { | |
int v = Integer.parseInt(ua.getBrowserVersion().getMajorVersion()); | |
return v >= 7; | |
} catch (NumberFormatException e) { | |
return false; | |
} | |
} else { | |
return false; | |
} | |
} | |
public static UserAgent fromHeaderString(String userAgentString) { | |
if (userAgentString != null) { | |
return new UserAgent(nl.bitwalker.useragentutils.UserAgent.parseUserAgentString(userAgentString)); | |
} else { | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment