com.android.sdklib.internal.repository.updater
Class PkgItem

java.lang.Object
  extended by com.android.sdklib.internal.repository.updater.PkgItem
All Implemented Interfaces:
java.lang.Comparable<PkgItem>

public class PkgItem
extends java.lang.Object
implements java.lang.Comparable<PkgItem>

A PkgItem represents one main Package combined with its state and an optional update package.

The main package is final and cannot change since it's what "defines" this PkgItem. The state or update package can change later.


Nested Class Summary
static class PkgItem.PkgState
          The state of the a given PkgItem, that is the relationship between a given remote package and the local repository.
 
Constructor Summary
PkgItem(Package mainPkg, PkgItem.PkgState state)
          Create a new PkgItem for this main package.
 
Method Summary
 int compareTo(PkgItem pkg)
           
 boolean equals(java.lang.Object obj)
          Equality is defined as isSameItemAs(PkgItem): state, main package and update package must be the similar.
 int getApi()
           
 Archive[] getArchives()
           
 java.lang.String getDescription()
           
 Package getMainPackage()
           
 java.lang.String getName()
           
 FullRevision getRevision()
           
 SdkSource getSource()
           
 PkgItem.PkgState getState()
           
 Package getUpdatePkg()
           
 boolean hasArchive(Archive archive)
          Returns true if this package or its updating packages contains the exact given archive.
 boolean hasCompatibleArchive()
          Returns true if the main package has at least one archive compatible with the current platform.
 int hashCode()
           
 boolean hasUpdatePkg()
           
 boolean isChecked()
           
 boolean isObsolete()
           
 boolean isSameItemAs(PkgItem item)
          Checks whether too PkgItem are the same.
 boolean isSameMainPackageAs(Package pkg)
          Checks whether the main packages are of the same type and are not an update of each other and have the same revision number.
 boolean isSameUpdatePackageAs(Package pkg)
          Checks whether the update packages are of the same type and are not an update of each other and have the same revision numbers.
 boolean mergeUpdate(Package pkg)
          Check whether the 'pkg' argument is an update for this package.
 void removeUpdate()
           
 void setChecked(boolean checked)
           
 java.lang.String toString()
          Returns a string representation of this item, useful when debugging.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PkgItem

public PkgItem(Package mainPkg,
               PkgItem.PkgState state)
Create a new PkgItem for this main package. The main package is final and cannot change since it's what "defines" this PkgItem. The state or update package can change later.

Method Detail

isObsolete

public boolean isObsolete()

isChecked

public boolean isChecked()

setChecked

public void setChecked(boolean checked)

getUpdatePkg

public Package getUpdatePkg()

hasUpdatePkg

public boolean hasUpdatePkg()

getName

public java.lang.String getName()

getRevision

public FullRevision getRevision()

getDescription

public java.lang.String getDescription()

getMainPackage

public Package getMainPackage()

getState

public PkgItem.PkgState getState()

getSource

public SdkSource getSource()

getApi

public int getApi()

getArchives

public Archive[] getArchives()

compareTo

public int compareTo(PkgItem pkg)
Specified by:
compareTo in interface java.lang.Comparable<PkgItem>

hasArchive

public boolean hasArchive(Archive archive)
Returns true if this package or its updating packages contains the exact given archive. Important: This compares object references, not object equality.


hasCompatibleArchive

public boolean hasCompatibleArchive()
Returns true if the main package has at least one archive compatible with the current platform.


isSameMainPackageAs

public boolean isSameMainPackageAs(Package pkg)
Checks whether the main packages are of the same type and are not an update of each other and have the same revision number.


isSameUpdatePackageAs

public boolean isSameUpdatePackageAs(Package pkg)
Checks whether the update packages are of the same type and are not an update of each other and have the same revision numbers.


isSameItemAs

public boolean isSameItemAs(PkgItem item)
Checks whether too PkgItem are the same. This checks both items have the same state, both main package are similar and that they have the same updating packages.


equals

public boolean equals(java.lang.Object obj)
Equality is defined as isSameItemAs(PkgItem): state, main package and update package must be the similar.

Overrides:
equals in class java.lang.Object

hashCode

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

mergeUpdate

public boolean mergeUpdate(Package pkg)
Check whether the 'pkg' argument is an update for this package. If it is, record it as an updating package. If there's already an updating package, only keep the most recent update. Returns true if it is update (even if there was already an update and this ended up not being the most recent), false if incompatible or not an update. This should only be used for installed packages.


removeUpdate

public void removeUpdate()

toString

public java.lang.String toString()
Returns a string representation of this item, useful when debugging.

Overrides:
toString in class java.lang.Object