Class DeviceMatch


  • public class DeviceMatch
    extends java.lang.Object
    Matches devices for Selectors.
    Author:
    Christopher Mindus
    • Constructor Summary

      Constructors 
      ConstructorDescription
      DeviceMatch() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethodDescription
      static booleanexists​(java.lang.String match)
      Checks if the match string exists.
      static java.lang.StringgetDescription​(java.lang.String match)
      Gets the device description for a string.
      static java.util.Map<java.lang.String,​java.lang.String>getMap()
      Gets the map of devices that can match with this class.
      static ua_parser.ClientgetParsedUserAgent​(EnvProps env)
      Gets the parsed user agent instance.
      static java.lang.StringgetUserAgent​(EnvProps env)
      Gets client "User Agent" string.
      static booleanisAndroid​(EnvProps env)
      Check for Android device (phone or tablet).
      static booleanisBlackberry​(EnvProps env)
      Check for Blackberry device.
      static booleanisDesktop​(EnvProps env)
      Check for desktop device.
      static booleanisiOS​(EnvProps env)
      Check for iOS device (iPhone or iPad).
      static booleanisMac​(EnvProps env)
      Check for Mac OS device.
      static booleanisWinPhone​(EnvProps env)
      Check for Windows Phone.
      static booleanmatch​(EnvProps envProps, java.lang.String match)
      Matches a device.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DeviceMatch

        public DeviceMatch()
    • Method Detail

      • match

        public static boolean match​(EnvProps envProps,
                                    java.lang.String match)
        Matches a device.
        Parameters:
        envProps - The Client environment properties.
        match - The match string.
        Returns:
        true for match, false otherwise.
      • getDescription

        public static java.lang.String getDescription​(java.lang.String match)
        Gets the device description for a string. This method is typically used in the Designer.
        Parameters:
        match - The match string.
        Returns:
        The description of the device matching, null for none.
      • exists

        public static boolean exists​(java.lang.String match)
        Checks if the match string exists.
        Parameters:
        match - The match string.
        Returns:
        true if it exists, false otherwise.
      • getMap

        public static java.util.Map<java.lang.String,​java.lang.String> getMap()
        Gets the map of devices that can match with this class.
        Returns:
        An unmodifiable map with the string match as keys and descriptions as values.
      • getUserAgent

        public static java.lang.String getUserAgent​(EnvProps env)
                                             throws java.lang.Exception
        Gets client "User Agent" string.
        Parameters:
        env - The environment for a client.
        Returns:
        The user agent string.
        Throws:
        java.lang.Exception - An exception due to failure in performing the test, with a message why it failed.
      • getParsedUserAgent

        public static ua_parser.Client getParsedUserAgent​(EnvProps env)
                                                   throws java.lang.Exception
        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:
        java.lang.Exception - An exception due to failure in performing the test, with a message why it failed.
      • isiOS

        public static boolean isiOS​(EnvProps env)
                             throws java.lang.Exception
        Check for iOS device (iPhone or iPad).
        Parameters:
        env - Environment properties
        Returns:
        true if the environment properties indicate a iOS device
        Throws:
        java.lang.Exception - An exception due to failure in performing the test, with a message why it failed.
      • isAndroid

        public static boolean isAndroid​(EnvProps env)
                                 throws java.lang.Exception
        Check for Android device (phone or tablet).
        Parameters:
        env - Environment properties.
        Returns:
        true if the environment properties indicate a Android device.
        Throws:
        java.lang.Exception - An exception due to failure in performing the test, with a message why it failed.
      • isWinPhone

        public static boolean isWinPhone​(EnvProps env)
                                  throws java.lang.Exception
        Check for Windows Phone.
        Parameters:
        env - Environment properties.
        Returns:
        true if the environment properties indicate a Windows Phone.
        Throws:
        java.lang.Exception - An exception due to failure in performing the test, with a message why it failed.
      • isBlackberry

        public static boolean isBlackberry​(EnvProps env)
                                    throws java.lang.Exception
        Check for Blackberry device.
        Parameters:
        env - Environment properties.
        Returns:
        true if the environment properties indicate a Blackberry device.
        Throws:
        java.lang.Exception - An exception due to failure in performing the test, with a message why it failed.
      • isMac

        public static boolean isMac​(EnvProps env)
                             throws java.lang.Exception
        Check for Mac OS device.
        Parameters:
        env - Environment properties.
        Returns:
        true if the environment properties indicate a Mac device.
        Throws:
        java.lang.Exception - An exception due to failure in performing the test, with a message why it failed.
      • isDesktop

        public static boolean isDesktop​(EnvProps env)
                                 throws java.lang.Exception
        Check for desktop device.
        Parameters:
        env - Environment properties
        Returns:
        true if the environment properties indicate a desktop device
        Throws:
        java.lang.Exception - An exception due to failure in performing the test, with a message why it failed.