com.android.sdklib.repository.descriptors
Class PkgDesc

java.lang.Object
  extended by com.android.sdklib.repository.descriptors.PkgDesc
All Implemented Interfaces:
IPkgCapabilities, IPkgDesc, java.lang.Comparable<IPkgDesc>
Direct Known Subclasses:
PkgDescExtra

public abstract class PkgDesc
extends java.lang.Object
implements IPkgDesc

PkgDesc keeps information on individual SDK packages (both local or remote packages definitions.)
Packages have different attributes depending on their type.

To create a new PkgDesc, use one of the package-specific constructors provided here.

To query packages capabilities, rely on getType() and the PkgDesc.hasXxx() methods provided in the base PkgDesc.


Constructor Summary
PkgDesc()
           
 
Method Summary
 int compareTo(IPkgDesc o)
          Compares this descriptor to another one.
 boolean equals(java.lang.Object obj)
           
 AndroidVersion getAndroidVersion()
          Returns the package's AndroidVersion or null.
 FullRevision getFullRevision()
          Returns the package's FullRevision or null.
 MajorRevision getMajorRevision()
          Returns the package's MajorRevision or null.
 FullRevision getMinPlatformToolsRev()
          Returns the package's min-platform-tools-rev or null.
 FullRevision getMinToolsRev()
          Returns the package's min-tools-rev or null.
 java.lang.String getPath()
          Returns the package's path string or null.
 IdDisplay getTag()
          Returns the package's tag id-display tuple or null.
abstract  PkgType getType()
          Returns the type of the package.
 java.lang.String getVendorId()
          Returns the package's vendor-id string or null.
 boolean hasAndroidVersion()
          Indicates whether this package type has a AndroidVersion.
 boolean hasFullRevision()
          Indicates whether this package type has a FullRevision.
 int hashCode()
           
 boolean hasMajorRevision()
          Indicates whether this package type has a MajorRevision.
 boolean hasMinPlatformToolsRev()
          Indicates whether this package type has a min-platform-tools-rev attribute.
 boolean hasMinToolsRev()
          Indicates whether this package type has a min-tools-rev attribute.
 boolean hasPath()
          Indicates whether this package type has a path.
 boolean hasTag()
          Indicates whether this package type has a tag.
 boolean hasVendorId()
          Indicates whether this package type has a vendor id.
protected  boolean isGenericUpdateFor(IPkgDesc existingDesc)
          Computes the most general case of IPkgDesc.isUpdateFor(IPkgDesc).
static IPkgDesc newAddon(AndroidVersion version, MajorRevision revision, IAddonDesc targetHashProvider)
          Create a new platform add-on descriptor where the target hash isn't determined yet.
static IPkgDesc newAddon(AndroidVersion version, MajorRevision revision, java.lang.String addonVendor, java.lang.String addonName)
          Create a new add-on package descriptor.
static IPkgDesc newBuildTool(FullRevision revision)
          Create a new build-tool package descriptor.
static IPkgDesc newDoc(AndroidVersion version, MajorRevision revision)
          Create a new doc package descriptor.
static IPkgDescExtra newExtra(java.lang.String vendorId, java.lang.String path, java.lang.String[] oldPaths, NoPreviewRevision revision)
          Create a new extra package descriptor.
static IPkgDesc newPlatform(AndroidVersion version, MajorRevision revision, FullRevision minToolsRev)
          Create a new platform package descriptor.
static IPkgDesc newPlatformTool(FullRevision revision)
          Create a new platform-tool package descriptor.
static IPkgDesc newSample(AndroidVersion version, MajorRevision revision, FullRevision minToolsRev)
          Create a new sample package descriptor.
static IPkgDesc newSource(AndroidVersion version, MajorRevision revision)
          Create a new source package descriptor.
static IPkgDesc newSysImg(AndroidVersion version, IdDisplay tag, java.lang.String abi, MajorRevision revision)
          Create a new system-image package descriptor.
static IPkgDesc newTool(FullRevision revision, FullRevision minPlatformToolsRev)
          Create a new tool package descriptor.
 java.lang.String toString()
          String representation for debugging purposes.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.android.sdklib.repository.descriptors.IPkgDesc
isUpdateFor
 

Constructor Detail

PkgDesc

public PkgDesc()
Method Detail

getType

@NonNull
public abstract PkgType getType()
Description copied from interface: IPkgDesc
Returns the type of the package.

Specified by:
getType in interface IPkgDesc
Returns:
Returns one of the PkgType constants.

hasFullRevision

public final boolean hasFullRevision()
Description copied from interface: IPkgCapabilities
Indicates whether this package type has a FullRevision.

Specified by:
hasFullRevision in interface IPkgCapabilities
Returns:
True if this package type has a FullRevision.

hasMajorRevision

public final boolean hasMajorRevision()
Description copied from interface: IPkgCapabilities
Indicates whether this package type has a MajorRevision.

Specified by:
hasMajorRevision in interface IPkgCapabilities
Returns:
True if this package type has a MajorRevision.

hasAndroidVersion

public final boolean hasAndroidVersion()
Description copied from interface: IPkgCapabilities
Indicates whether this package type has a AndroidVersion.

Specified by:
hasAndroidVersion in interface IPkgCapabilities
Returns:
True if this package type has a AndroidVersion.

hasPath

public final boolean hasPath()
Description copied from interface: IPkgCapabilities
Indicates whether this package type has a path.

Specified by:
hasPath in interface IPkgCapabilities
Returns:
True if this package type has a path.

hasTag

public final boolean hasTag()
Description copied from interface: IPkgCapabilities
Indicates whether this package type has a tag.

Specified by:
hasTag in interface IPkgCapabilities
Returns:
True if this package type has a tag id-display tuple.

hasVendorId

public boolean hasVendorId()
Description copied from interface: IPkgCapabilities
Indicates whether this package type has a vendor id.

Specified by:
hasVendorId in interface IPkgCapabilities
Returns:
True if this package type has a vendor id.

hasMinToolsRev

public final boolean hasMinToolsRev()
Description copied from interface: IPkgCapabilities
Indicates whether this package type has a min-tools-rev attribute.

Specified by:
hasMinToolsRev in interface IPkgCapabilities
Returns:
True if this package type has a min-tools-rev attribute.

hasMinPlatformToolsRev

public final boolean hasMinPlatformToolsRev()
Description copied from interface: IPkgCapabilities
Indicates whether this package type has a min-platform-tools-rev attribute.

Specified by:
hasMinPlatformToolsRev in interface IPkgCapabilities
Returns:
True if this package type has a min-platform-tools-rev attribute.

getFullRevision

@Nullable
public FullRevision getFullRevision()
Description copied from interface: IPkgDesc
Returns the package's FullRevision or null.

Specified by:
getFullRevision in interface IPkgDesc
Returns:
A non-null value if IPkgCapabilities.hasFullRevision() is true; otherwise a null value.

getMajorRevision

@Nullable
public MajorRevision getMajorRevision()
Description copied from interface: IPkgDesc
Returns the package's MajorRevision or null.

Specified by:
getMajorRevision in interface IPkgDesc
Returns:
A non-null value if IPkgCapabilities.hasMajorRevision() is true; otherwise a null value.

getAndroidVersion

@Nullable
public AndroidVersion getAndroidVersion()
Description copied from interface: IPkgDesc
Returns the package's AndroidVersion or null.

Specified by:
getAndroidVersion in interface IPkgDesc
Returns:
A non-null value if IPkgCapabilities.hasAndroidVersion() is true; otherwise a null value.

getPath

@Nullable
public java.lang.String getPath()
Description copied from interface: IPkgDesc
Returns the package's path string or null.

For PkgType.PKG_SYS_IMAGES, the path is the system-image ABI.
For PkgType.PKG_PLATFORMS, the path is the platform hash string.
For PkgType.PKG_ADDONS, the path is the platform hash string.
For PkgType.PKG_EXTRAS, the path is the extra-path string.

Specified by:
getPath in interface IPkgDesc
Returns:
A non-null value if IPkgCapabilities.hasPath() is true; otherwise a null value.

getTag

@Nullable
public IdDisplay getTag()
Description copied from interface: IPkgDesc
Returns the package's tag id-display tuple or null.

Specified by:
getTag in interface IPkgDesc
Returns:
A non-null tag if IPkgCapabilities.hasTag() is true; otherwise a null value.

getVendorId

@Nullable
public java.lang.String getVendorId()
Description copied from interface: IPkgDesc
Returns the package's vendor-id string or null.

Specified by:
getVendorId in interface IPkgDesc
Returns:
A non-null value if IPkgCapabilities.hasVendorId() is true; otherwise a null value.

getMinToolsRev

@Nullable
public FullRevision getMinToolsRev()
Description copied from interface: IPkgDesc
Returns the package's min-tools-rev or null.

Specified by:
getMinToolsRev in interface IPkgDesc
Returns:
A non-null value if IPkgCapabilities.hasMinToolsRev() is true; otherwise a null value.

getMinPlatformToolsRev

@Nullable
public FullRevision getMinPlatformToolsRev()
Description copied from interface: IPkgDesc
Returns the package's min-platform-tools-rev or null.

Specified by:
getMinPlatformToolsRev in interface IPkgDesc
Returns:
A non-null value if IPkgCapabilities.hasMinPlatformToolsRev() is true; otherwise null.

isGenericUpdateFor

protected final boolean isGenericUpdateFor(@NonNull
                                           IPkgDesc existingDesc)
Computes the most general case of IPkgDesc.isUpdateFor(IPkgDesc). Individual package types use this and complement with their own specific cases as needed.

Parameters:
existingDesc - A non-null package descriptor to compare with.
Returns:
True if this package descriptor would generally update the given one.

compareTo

public int compareTo(@NonNull
                     IPkgDesc o)
Compares this descriptor to another one. All fields must match for equality.

This is must not be used an indication that a package is a suitable update for another one. The comparison order is however suitable for sorting packages for display purposes.

Specified by:
compareTo in interface java.lang.Comparable<IPkgDesc>

toString

public java.lang.String toString()
String representation for debugging purposes.

Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

newTool

@NonNull
public static IPkgDesc newTool(@NonNull
                                       FullRevision revision,
                                       @NonNull
                                       FullRevision minPlatformToolsRev)
Create a new tool package descriptor.

Parameters:
revision - The revision of the tool package.
minPlatformToolsRev - The min-platform-tools-rev. Use FullRevision.NOT_SPECIFIED to indicate there is no requirement.
Returns:
A PkgDesc describing this tool package.

newPlatformTool

@NonNull
public static IPkgDesc newPlatformTool(@NonNull
                                               FullRevision revision)
Create a new platform-tool package descriptor.

Parameters:
revision - The revision of the platform-tool package.
Returns:
A PkgDesc describing this platform-tool package.

newBuildTool

@NonNull
public static IPkgDesc newBuildTool(@NonNull
                                            FullRevision revision)
Create a new build-tool package descriptor.

Parameters:
revision - The revision of the build-tool package.
Returns:
A PkgDesc describing this build-tool package.

newDoc

@NonNull
public static IPkgDesc newDoc(@NonNull
                                      AndroidVersion version,
                                      @NonNull
                                      MajorRevision revision)
Create a new doc package descriptor.

Parameters:
revision - The revision of the doc package.
Returns:
A PkgDesc describing this doc package.

newExtra

@NonNull
public static IPkgDescExtra newExtra(@NonNull
                                             java.lang.String vendorId,
                                             @NonNull
                                             java.lang.String path,
                                             @Nullable
                                             java.lang.String[] oldPaths,
                                             @NonNull
                                             NoPreviewRevision revision)
Create a new extra package descriptor.

Parameters:
vendorId - The vendor id string of the extra package.
path - The path id string of the extra package.
oldPaths - An optional list of older paths for this extra package.
revision - The revision of the extra package.
Returns:
A PkgDesc describing this extra package.

newPlatform

@NonNull
public static IPkgDesc newPlatform(@NonNull
                                           AndroidVersion version,
                                           @NonNull
                                           MajorRevision revision,
                                           @NonNull
                                           FullRevision minToolsRev)
Create a new platform package descriptor.

Parameters:
version - The android version of the platform package.
revision - The revision of the extra package.
minToolsRev - An optional min-tools-rev. Use FullRevision.NOT_SPECIFIED to indicate there is no requirement.
Returns:
A PkgDesc describing this platform package.

newAddon

@NonNull
public static IPkgDesc newAddon(@NonNull
                                        AndroidVersion version,
                                        @NonNull
                                        MajorRevision revision,
                                        @NonNull
                                        java.lang.String addonVendor,
                                        @NonNull
                                        java.lang.String addonName)
Create a new add-on package descriptor.

The vendor id and the name id provided are used to compute the add-on's target hash.

Parameters:
version - The android version of the add-on package.
revision - The revision of the add-on package.
addonVendor - The vendor id of the add-on package.
addonName - The name id of the add-on package.
Returns:
A PkgDesc describing this add-on package.

newAddon

@NonNull
public static IPkgDesc newAddon(@NonNull
                                        AndroidVersion version,
                                        @NonNull
                                        MajorRevision revision,
                                        @NonNull
                                        IAddonDesc targetHashProvider)
Create a new platform add-on descriptor where the target hash isn't determined yet.

Parameters:
version - The android version of the add-on package.
revision - The revision of the add-on package.
targetHashProvider - Implements a method that will return the target hash when needed.
Returns:
A PkgDesc describing this add-on package.

newSysImg

@NonNull
public static IPkgDesc newSysImg(@NonNull
                                         AndroidVersion version,
                                         @NonNull
                                         IdDisplay tag,
                                         @NonNull
                                         java.lang.String abi,
                                         @NonNull
                                         MajorRevision revision)
Create a new system-image package descriptor.

For system-images, getPath() returns the ABI.

Parameters:
version - The android version of the system-image package.
tag - The tag of the system-image package.
abi - The ABI of the system-image package.
revision - The revision of the system-image package.
Returns:
A PkgDesc describing this system-image package.

newSource

@NonNull
public static IPkgDesc newSource(@NonNull
                                         AndroidVersion version,
                                         @NonNull
                                         MajorRevision revision)
Create a new source package descriptor.

Parameters:
version - The android version of the source package.
revision - The revision of the source package.
Returns:
A PkgDesc describing this source package.

newSample

@NonNull
public static IPkgDesc newSample(@NonNull
                                         AndroidVersion version,
                                         @NonNull
                                         MajorRevision revision,
                                         @NonNull
                                         FullRevision minToolsRev)
Create a new sample package descriptor.

Parameters:
version - The android version of the sample package.
revision - The revision of the sample package.
minToolsRev - An optional min-tools-rev. Use FullRevision.NOT_SPECIFIED to indicate there is no requirement.
Returns:
A PkgDesc describing this sample package.