public class UserAgent extends Object
This class only provides valid information for requests by browsers or clients which do transmit an user agent. If no user agent is transmitted, the client is considered as desktop.
Assumptions of device properties based on user agents might not be accurate all the time as some browsers transmit some special user agents and user agents for different browsers and devices might change over time.
Constructor and Description |
---|
UserAgent(String userAgentString)
Creates a new instance based on the given user agent string.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(String userAgentPart)
Determines if the user agent contains the given value.
|
String |
getUserAgentString()
Returns the user agent as String.
|
boolean |
is(String expectedUserAgent)
Determines if the user agent is equal to the given value.
|
boolean |
isAndroid()
Determines whether the user agent hints to an Android device.
|
boolean |
isDesktop()
Determines whether the user agent hits to a desktop device.
|
boolean |
isIOS()
Determines whether the user agent hints to an iOS device.
|
boolean |
isMobile()
Determines whether the user agent hints to a mobile device.
|
boolean |
isPhone()
Determines whether the user agent hints to a phone.
|
boolean |
isTablet()
Determines whether the user agent hints to a tablet.
|
protected void |
parseUserAgent() |
public UserAgent(String userAgentString)
userAgentString
- the header value indicating the user angent, which is a fancy word for browser.protected void parseUserAgent()
public boolean isMobile()
public boolean isPhone()
public boolean isTablet()
public boolean isDesktop()
public boolean isAndroid()
public boolean isIOS()
public String getUserAgentString()
public boolean is(@Nonnull String expectedUserAgent)
expectedUserAgent
- the expected user agentCopyright © 2018. All rights reserved.