Class DeviceMatch
java.lang.Object
com.iizix.selector.DeviceMatch
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe device class of a desktop or a notebook.static final StringThe device class of a phone.static final StringThe device class of a tablet.static final StringThe client environment key of the device class the client reported: "phone", "tablet" or "desktop" (iz/client.jsclassifyDevice); absent for a client from before v5.static final StringThe client environment key of the operating system the client reported: "iOS", "Android", "Windows", "macOS", "Linux", "ChromeOS" or "Unknown".Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionstatic booleanChecks if the match string exists.static StringgetDescription(String match) Gets the device description for a string.static io.github.mngsk.devicedetector.DetectionGets the cached device detection instance based on the parsed user agent.static StringGets the Operating System from the cached device detection instance based on the parsed user agent.static StringgetDeviceValue(EnvProps env, String key) Gets a value the client reported in its client environment, such asDEV_CLASS.static StringGets the family of a match string, as the Designer groups them.getMap()Gets the map of devices that can match with this class.static ua_parser.ClientGets the parsed user agent instance.Gets the map of the retired match strings.static StringgetRetiredMessage(String match) Gets the message for a retired match string, as the verification and the Designer show it.static StringgetRetiredText(String match) Gets what to use instead of a retired match string.static StringgetSelectorMatch(String userAgent) Generate output for a User Agent with every possible selector match.static StringgetUserAgent(EnvProps env) Gets client "User Agent" string.static booleanCheck for Android device (phone or tablet).static booleanDeprecated.static booleanCheck for iOS device (iPhone or iPad).static booleanCheck for Mac OS device.static booleanChecks if the match string was retired in v5.static booleanisWinPhone(EnvProps env) Check for Windows Phone.static booleanMatches a device.
Field Details
DEV_CLASS
The client environment key of the device class the client reported: "phone", "tablet" or "desktop" (iz/client.jsclassifyDevice); absent for a client from before v5.- See Also:
DEV_OS
The client environment key of the operating system the client reported: "iOS", "Android", "Windows", "macOS", "Linux", "ChromeOS" or "Unknown".- See Also:
CLASS_PHONE
CLASS_TABLET
CLASS_DESKTOP
Constructor Details
DeviceMatch
public DeviceMatch()
Method Details
getDeviceValue
match
Matches a device.A retired or unknown match string answers false and is logged as a warning once per JVM, not at every evaluation: a selector naming one is evaluated at every panel choice.
- Parameters:
envProps- The Client environment properties.match- The match string.- Returns:
- true for match, false otherwise.
getDescription
exists
Checks if the match string exists.- Parameters:
match- The match string.- Returns:
- true if it exists, false otherwise.
isRetired
Checks if the match string was retired in v5. A retired string does not exist (exists(String)is false), matches nothing and verifies as a warning, not as an error, so that a selector file naming it still loads.- Parameters:
match- The match string.- Returns:
- true if it was retired, false otherwise.
getRetiredText
getRetiredMessage
getRetiredMap
getFamily
getMap
getUserAgent
getParsedUserAgent
Gets the parsed user agent instance.- Parameters:
env- The environment for a client.- Returns:
- The parsed user agent for the client, a cached value (i.e. parsed once only).
- Throws:
Exception- An exception due to failure in performing the test, with a message why it failed.
getDeviceDetectionFromUserAgent
public static io.github.mngsk.devicedetector.Detection getDeviceDetectionFromUserAgent(EnvProps env) throws Exception Gets the cached device detection instance based on the parsed user agent.- Parameters:
env- The environment for a client.- Returns:
- The cached device detection instance based on the parsed user agent (i.e. parsed once only).
- Throws:
Exception- An exception due to failure in performing the test, with a message why it failed.
getDeviceDetectionOperatingSystemFromUserAgent
Gets the Operating System from the cached device detection instance based on the parsed user agent.- Parameters:
env- The environment for a client.- Returns:
- The OS.
- Throws:
Exception- An exception due to failure in performing the test, with a message why it failed.
isiOS
isAndroid
Check for Android device (phone or tablet).- Parameters:
env- Environment properties.- Returns:
- true if the environment properties indicate a Android device.
- Throws:
Exception- An exception due to failure in performing the test, with a message why it failed.
isWinPhone
isMac
isDesktop
Deprecated.Use the method{@link #getDeviceDetectionFromUserAgent(EnvProps)}.isDesktop()instead.Check for desktop device.This method returns the value from
{@link #getDeviceDetectionFromUserAgent(EnvProps)}.isDesktop().- Parameters:
env- Environment properties- Returns:
- true if the environment properties indicate a desktop device
- Throws:
Exception- An exception due to failure in performing the test, with a message why it failed.
getSelectorMatch
{@link #getDeviceDetectionFromUserAgent(EnvProps)}.isDesktop()instead.