com.android.sdklib.repository.descriptors
Class PkgDesc

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

public 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.


Nested Class Summary
static class PkgDesc.Builder
           
static interface PkgDesc.IGetPath
           
static interface PkgDesc.IIsUpdateFor
           
 
Field Summary
static java.lang.String PREVIEW_SUFFIX
           
 
Constructor Summary
protected PkgDesc(PkgType type, License license, java.lang.String listDisplay, java.lang.String descriptionShort, java.lang.String descriptionUrl, boolean isObsolete, FullRevision fullRevision, MajorRevision majorRevision, AndroidVersion androidVersion, java.lang.String path, IdDisplay tag, IdDisplay vendor, FullRevision minToolsRev, FullRevision minPlatformToolsRev, PkgDesc.IIsUpdateFor customIsUpdateFor, PkgDesc.IGetPath customPath)
           
 
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.
 java.lang.String getBaseInstallId()
          Returns a stable string id that can be used to reference this package, which excludes the preview suffix.
 java.io.File getCanonicalInstallFolder(java.io.File sdkLocation)
          Returns the canonical location where such a package would be installed.
 java.lang.String getDescriptionShort()
           
 java.lang.String getDescriptionUrl()
           
 FullRevision getFullRevision()
          Returns the package's FullRevision or null.
 java.lang.String getInstallId()
          Returns a stable string id that can be used to reference this package, including a suffix indicating that this package is a preview if it is.
 License getLicense()
           
 java.lang.String getListDescription()
          Returns a description of this package that is suitable for a list display.
 java.lang.String getListDisplay()
          Returns the list-display meta data of this package.
 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.
 PreciseRevision getPreciseRevision()
          Returns the package's revision or null.
 IdDisplay getTag()
          Returns the package's tag id-display tuple or null.
 PkgType getType()
          Returns the type of the package.
 IdDisplay getVendor()
          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 hasVendor()
          Indicates whether this package type has a vendor id.
 boolean isObsolete()
           
 boolean isPreview()
           
 boolean isUpdateFor(IPkgDesc existingDesc)
          Computes the most general case of isUpdateFor(IPkgDesc).
 boolean isUpdateFor(IPkgDesc existingDesc, FullRevision.PreviewComparison previewComparison)
          Indicates whether this package descriptor is an update for the given existing descriptor, using the given comparison method.
protected  java.lang.String patternReplaceImpl(java.lang.String result)
           
 java.lang.String toString()
          String representation for debugging purposes.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PREVIEW_SUFFIX

public static final java.lang.String PREVIEW_SUFFIX
See Also:
Constant Field Values
Constructor Detail

PkgDesc

protected PkgDesc(@NonNull
                  PkgType type,
                  @Nullable
                  License license,
                  @Nullable
                  java.lang.String listDisplay,
                  @Nullable
                  java.lang.String descriptionShort,
                  @Nullable
                  java.lang.String descriptionUrl,
                  boolean isObsolete,
                  @Nullable
                  FullRevision fullRevision,
                  @Nullable
                  MajorRevision majorRevision,
                  @Nullable
                  AndroidVersion androidVersion,
                  @Nullable
                  java.lang.String path,
                  @Nullable
                  IdDisplay tag,
                  @Nullable
                  IdDisplay vendor,
                  @Nullable
                  FullRevision minToolsRev,
                  @Nullable
                  FullRevision minPlatformToolsRev,
                  @Nullable
                  PkgDesc.IIsUpdateFor customIsUpdateFor,
                  @Nullable
                  PkgDesc.IGetPath customPath)
Method Detail

getType

@NonNull
public 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.

getListDisplay

@Nullable
public java.lang.String getListDisplay()
Description copied from interface: IPkgDesc
Returns the list-display meta data of this package.

Specified by:
getListDisplay in interface IPkgDesc
Returns:
The list-display data, if available, or null.

getDescriptionShort

@Nullable
public java.lang.String getDescriptionShort()
Specified by:
getDescriptionShort in interface IPkgDesc

getDescriptionUrl

@Nullable
public java.lang.String getDescriptionUrl()
Specified by:
getDescriptionUrl in interface IPkgDesc

getLicense

@Nullable
public License getLicense()
Specified by:
getLicense in interface IPkgDesc

isObsolete

public boolean isObsolete()
Specified by:
isObsolete in interface IPkgDesc

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.

hasVendor

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

Specified by:
hasVendor 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.

getPreciseRevision

@NonNull
public final PreciseRevision getPreciseRevision()
Description copied from interface: IPkgDesc
Returns the package's revision or null. This will come from the FullRevision or MajorRevision, with the precision set as appropriate.

Specified by:
getPreciseRevision in interface IPkgDesc
Returns:
A representation of IPkgDesc.getMajorRevision() or IPkgDesc.getFullRevision(), depending on which one exists.

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.

isPreview

public boolean isPreview()
Specified by:
isPreview in interface IPkgDesc
Returns:
True if the revision of this package is a preview.

getPath

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

For PkgType.PKG_SYS_IMAGE, the path is the system-image ABI.
For PkgType.PKG_PLATFORM, the path is the platform hash string.
For PkgType.PKG_ADDON, the path is the platform hash string.
For PkgType.PKG_EXTRA, 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.

getVendor

@Nullable
public IdDisplay getVendor()
Description copied from interface: IPkgDesc
Returns the package's vendor-id string or null.

Specified by:
getVendor in interface IPkgDesc
Returns:
A non-null value if IPkgCapabilities.hasVendor() 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.

getInstallId

public java.lang.String getInstallId()
Description copied from interface: IPkgDesc
Returns a stable string id that can be used to reference this package, including a suffix indicating that this package is a preview if it is.

Specified by:
getInstallId in interface IPkgDesc

getBaseInstallId

public java.lang.String getBaseInstallId()
Description copied from interface: IPkgDesc
Returns a stable string id that can be used to reference this package, which excludes the preview suffix.

Specified by:
getBaseInstallId in interface IPkgDesc

getCanonicalInstallFolder

public java.io.File getCanonicalInstallFolder(@NonNull
                                              java.io.File sdkLocation)
Description copied from interface: IPkgDesc
Returns the canonical location where such a package would be installed.

Specified by:
getCanonicalInstallFolder in interface IPkgDesc
Parameters:
sdkLocation - The root of the SDK.
Returns:
the canonical location where such a package would be installed.

isUpdateFor

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

Specified by:
isUpdateFor in interface IPkgDesc
Parameters:
existingDesc - A non-null package descriptor to compare with.
Returns:
True if this package descriptor would generally update the given one.

isUpdateFor

public boolean isUpdateFor(@NonNull
                           IPkgDesc existingDesc,
                           @NonNull
                           FullRevision.PreviewComparison previewComparison)
Description copied from interface: IPkgDesc
Indicates whether this package descriptor is an update for the given existing descriptor, using the given comparison method.

Specified by:
isUpdateFor in interface IPkgDesc
Parameters:
existingDesc - A non-null existing descriptor.
previewComparison - The FullRevision.PreviewComparison method to use when comparing the packages.
Returns:
True if this package is an update for 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>

getListDescription

@NonNull
public java.lang.String getListDescription()
Description copied from interface: IListDescription
Returns a description of this package that is suitable for a list display. Should not be empty. Must never be null.

Note that this is the "base" name for the package with no specific revision nor API mentioned. In contrast, IDescription.getShortDescription() should be used if you want more details such as the package revision number or the API, if applicable.

Specified by:
getListDescription in interface IListDescription

patternReplaceImpl

protected java.lang.String patternReplaceImpl(java.lang.String result)

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