Class AndroidTargetHash


  • public abstract class AndroidTargetHash
    extends java.lang.Object
    Helper methods to manipulate hash strings used by IAndroidTarget.hashString().
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String PLATFORM_HASH_PREFIX
      Prefix used to build hash strings for platform targets
      static java.lang.String SYSTEM_IMAGE_PREFIX
      Prefix used to build hash strings for system image targets
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getAddonHashString​(java.lang.String addonVendorDisplay, java.lang.String addonNameDisplay, com.android.sdklib.AndroidVersion version)
      Returns the hash string for a given add-on.
      static com.android.sdklib.AndroidVersion getAddOnVersion​(java.lang.String hashString)  
      static java.lang.String getPlatformHashString​(com.android.sdklib.AndroidVersion version)
      Returns the hash string for a given platform version.
      static com.android.sdklib.AndroidVersion getPlatformVersion​(java.lang.String hashString)
      Returns the AndroidVersion for the given hash string, if it represents a platform.
      static java.lang.String getTargetHashString​(IAndroidTarget target)
      Returns the hash string for a given target (add-on or platform.)
      static com.android.sdklib.AndroidVersion getVersionFromHash​(java.lang.String hashString)
      Gets the API level from a hash string, either a platform version or add-on version.
      static boolean isPlatform​(java.lang.String hashString)
      Given a hash string, indicates whether this is a platform hash string.
      static boolean isSystemImage​(java.lang.String hashString)  
      • Methods inherited from class java.lang.Object

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

      • AndroidTargetHash

        public AndroidTargetHash()
    • Method Detail

      • getPlatformHashString

        @NonNull
        public static java.lang.String getPlatformHashString​(@NonNull
                                                             com.android.sdklib.AndroidVersion version)
        Returns the hash string for a given platform version.
        Parameters:
        version - A non-null platform version.
        Returns:
        A non-null hash string uniquely representing this platform target.
      • getPlatformVersion

        @Nullable
        public static com.android.sdklib.AndroidVersion getPlatformVersion​(@NonNull
                                                                           java.lang.String hashString)
        Returns the AndroidVersion for the given hash string, if it represents a platform. If the hash string represents a preview platform, the returned AndroidVersion will have an unknown API level (set to 1 or a known matching API level.)
        Parameters:
        hashString - the hash string (e.g. "android-19" or "android-CUPCAKE") or a pure API level for convenience (e.g. "19" instead of the proper "android-19")
        Returns:
        a platform, or null
      • getAddOnVersion

        @Nullable
        public static com.android.sdklib.AndroidVersion getAddOnVersion​(@NonNull
                                                                        java.lang.String hashString)
      • getVersionFromHash

        @Nullable
        public static com.android.sdklib.AndroidVersion getVersionFromHash​(@NonNull
                                                                           java.lang.String hashString)
        Gets the API level from a hash string, either a platform version or add-on version.
        See Also:
        getAddOnVersion(String), getPlatformVersion(String)
      • getAddonHashString

        public static java.lang.String getAddonHashString​(@NonNull
                                                          java.lang.String addonVendorDisplay,
                                                          @NonNull
                                                          java.lang.String addonNameDisplay,
                                                          @NonNull
                                                          com.android.sdklib.AndroidVersion version)
        Returns the hash string for a given add-on.
        Parameters:
        addonVendorDisplay - A non-null vendor. When using an IdDisplay source, this parameter should be the IdDisplay.getDisplay().
        addonNameDisplay - A non-null add-on name. When using an IdDisplay source, this parameter should be the IdDisplay.getDisplay().
        version - A non-null platform version (the addon's base platform version)
        Returns:
        A non-null hash string uniquely representing this add-on target.
      • getTargetHashString

        public static java.lang.String getTargetHashString​(@NonNull
                                                           IAndroidTarget target)
        Returns the hash string for a given target (add-on or platform.)
        Parameters:
        target - A non-null target.
        Returns:
        A non-null hash string uniquely representing this target.
      • isPlatform

        public static boolean isPlatform​(@NonNull
                                         java.lang.String hashString)
        Given a hash string, indicates whether this is a platform hash string. If not, it's an addon hash string.
        Parameters:
        hashString - The hash string to test.
        Returns:
        True if this hash string starts by the platform prefix.
      • isSystemImage

        public static boolean isSystemImage​(@NonNull
                                            java.lang.String hashString)