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

java.lang.Object
  extended by com.android.sdklib.internal.repository.archives.ArchiveReplacement
      extended by com.android.sdklib.internal.repository.updater.ArchiveInfo
All Implemented Interfaces:
IDescription, java.lang.Comparable<ArchiveInfo>

public class ArchiveInfo
extends ArchiveReplacement
implements java.lang.Comparable<ArchiveInfo>

Represents an archive that we want to install. Note that the installer deals with archives whereas the user mostly sees packages but as far as we are concerned for installation there's a 1-to-1 mapping.

A new archive is always a remote archive that needs to be downloaded and then installed. It can replace an existing local one. It can also depends on another (new or local) archive, which means the dependent archive needs to be successfully installed first. Finally this archive can also be a dependency for another one.

The accepted and rejected flags are used by SdkUpdaterChooserDialog to follow user choices. The installer should never install something that is not accepted.

Note: There is currently no logic to support more than one level of dependency, either here or in the SdkUpdaterChooserDialog, since we currently have no need for it.

See Also:
ArchiveInfo(Archive, Archive, ArchiveInfo[])

Constructor Summary
ArchiveInfo(Archive newArchive, Archive replaced, ArchiveInfo[] dependsOn)
          Creates a new replacement where the newArchive will replace the currently installed replaced archive.
 
Method Summary
 ArchiveInfo addDependencyFor(ArchiveInfo dependencyFor)
          Adds an ArchiveInfo for which this package is a dependency.
 int compareTo(ArchiveInfo rhs)
          ArchiveInfos are compared using ther "new archive" ordering.
 java.util.Collection<ArchiveInfo> getDependenciesFor()
          Returns the list of ArchiveInfo for which this package is a dependency.
 ArchiveInfo[] getDependsOn()
          Returns an optional new or local dependency, that is an archive that this archive depends upon.
 boolean isAccepted()
          Returns whether this archive was accepted (either manually by the user or automatically if it doesn't have a license) for installation.
 boolean isDependencyFor()
          Returns true if this new archive is a dependency for another one that we want to install.
 boolean isRejected()
          Returns whether this archive was rejected manually by the user.
 void setAccepted(boolean accepted)
          Sets whether this archive was accepted (either manually by the user or automatically if it doesn't have a license) for installation.
 void setRejected(boolean rejected)
          Sets whether this archive was rejected manually by the user.
 
Methods inherited from class com.android.sdklib.internal.repository.archives.ArchiveReplacement
getLongDescription, getNewArchive, getReplaced, getShortDescription, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArchiveInfo

public ArchiveInfo(@Nullable
                   Archive newArchive,
                   @Nullable
                   Archive replaced,
                   @Nullable
                   ArchiveInfo[] dependsOn)
Creates a new replacement where the newArchive will replace the currently installed replaced archive. When newArchive is not intended to replace anything (e.g. because the user is installing a new package not present on her system yet), then replace shall be null.

Parameters:
newArchive - A "new archive" to be installed. This is always an archive that comes from a remote site. This may be null.
replaced - An optional local archive that the new one will replace. Can be null if this archive does not replace anything.
dependsOn - An optional new or local dependency, that is an archive that this archive depends upon. In other words, we can only install this archive if the dependency has been successfully installed. It also means we need to install the dependency first. Can be null or empty. However it cannot contain nulls.
Method Detail

getDependsOn

@Nullable
public ArchiveInfo[] getDependsOn()
Returns an optional new or local dependency, that is an archive that this archive depends upon. In other words, we can only install this archive if the dependency has been successfully installed. It also means we need to install the dependency first.

This array can be null or empty. It can't contain nulls though.


isDependencyFor

public boolean isDependencyFor()
Returns true if this new archive is a dependency for another one that we want to install.


addDependencyFor

@NonNull
public ArchiveInfo addDependencyFor(ArchiveInfo dependencyFor)
Adds an ArchiveInfo for which this package is a dependency. This means the package added here depends on this package.


getDependenciesFor

@NonNull
public java.util.Collection<ArchiveInfo> getDependenciesFor()
Returns the list of ArchiveInfo for which this package is a dependency. This means the packages listed here depend on this package.

Implementation detail: this is the internal mutable list. Callers should not modify it. This list can be empty but is never null.


setAccepted

public void setAccepted(boolean accepted)
Sets whether this archive was accepted (either manually by the user or automatically if it doesn't have a license) for installation.


isAccepted

public boolean isAccepted()
Returns whether this archive was accepted (either manually by the user or automatically if it doesn't have a license) for installation.


setRejected

public void setRejected(boolean rejected)
Sets whether this archive was rejected manually by the user. An archive can neither accepted nor rejected.


isRejected

public boolean isRejected()
Returns whether this archive was rejected manually by the user. An archive can neither accepted nor rejected.


compareTo

public int compareTo(ArchiveInfo rhs)
ArchiveInfos are compared using ther "new archive" ordering.

Specified by:
compareTo in interface java.lang.Comparable<ArchiveInfo>
See Also:
Archive.compareTo(Archive)