com.android.sdklib
Class AndroidTargetHash

java.lang.Object
  extended by com.android.sdklib.AndroidTargetHash

public abstract class AndroidTargetHash
extends java.lang.Object

Helper methods to manipulate hash strings used by IAndroidTarget.hashString().


Field Summary
static java.lang.String ADD_ON_FORMAT
          String to compute hash for add-on targets.
static java.lang.String PLATFORM_HASH_PREFIX
          Prefix used to build hash strings for platform targets
 
Constructor Summary
AndroidTargetHash()
           
 
Method Summary
static java.lang.String getAddonHashString(java.lang.String addonVendorDisplay, java.lang.String addonNameDisplay, AndroidVersion version)
          Returns the hash string for a given add-on.
static AndroidVersion getAddOnVersion(java.lang.String hashString)
           
static java.lang.String getPlatformHashString(AndroidVersion version)
          Returns the hash string for a given platform version.
static 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLATFORM_HASH_PREFIX

public static final java.lang.String PLATFORM_HASH_PREFIX
Prefix used to build hash strings for platform targets

See Also:
SdkManager.getTargetFromHashString(String), Constant Field Values

ADD_ON_FORMAT

public static final java.lang.String ADD_ON_FORMAT
String to compute hash for add-on targets.
Format is vendor:name:apiVersion.
Important: the vendor and name compontents are the display strings, not the newer id strings.

See Also:
Constant Field Values
Constructor Detail

AndroidTargetHash

public AndroidTargetHash()
Method Detail

getPlatformHashString

@NonNull
public static java.lang.String getPlatformHashString(@NonNull
                                                             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 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 AndroidVersion getAddOnVersion(@NonNull
                                                      java.lang.String hashString)

getVersionFromHash

@Nullable
public static 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
                                                  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.