2 * Copyright (C) 2009 The Android Open Source Project
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 package com.android.sdkuilib.internal.repository;
\r
19 import com.android.sdklib.internal.repository.Archive;
\r
21 import java.util.ArrayList;
\r
22 import java.util.Collection;
\r
25 * Represents an archive that we want to install.
\r
26 * Note that the installer deals with archives whereas the user mostly sees packages
\r
27 * but as far as we are concerned for installation there's a 1-to-1 mapping.
\r
29 * A new archive is always a remote archive that needs to be downloaded and then
\r
30 * installed. It can replace an existing local one. It can also depends on another
\r
31 * (new or local) archive, which means the dependent archive needs to be successfully
\r
32 * installed first. Finally this archive can also be a dependency for another one.
\r
34 * @see ArchiveInfo#ArchiveInfo(Archive, Archive, ArchiveInfo)
\r
38 private final Archive mNewArchive;
\r
39 private final Archive mReplaced;
\r
40 private final ArchiveInfo mDependsOn;
\r
41 private final ArrayList<ArchiveInfo> mDependencyFor = new ArrayList<ArchiveInfo>();
\r
42 private boolean mAccepted;
\r
43 private boolean mRejected;
\r
47 * @param newArchive A "new archive" to be installed. This is always an archive
\r
48 * that comes from a remote site. This can not be null.
\r
49 * @param replaced An optional local archive that the new one will replace.
\r
50 * Can be null if this archive does not replace anything.
\r
51 * @param dependsOn An optional new or local dependency, that is an archive that
\r
52 * <em>this</em> archive depends upon. In other words, we can only install
\r
53 * this archive if the dependency has been successfully installed. It also
\r
54 * means we need to install the dependency first.
\r
56 public ArchiveInfo(Archive newArchive, Archive replaced, ArchiveInfo dependsOn) {
\r
57 mNewArchive = newArchive;
\r
58 mReplaced = replaced;
\r
59 mDependsOn = dependsOn;
\r
63 * Returns the "new archive" to be installed.
\r
64 * This is always an archive that comes from a remote site.
\r
66 public Archive getNewArchive() {
\r
71 * Returns an optional local archive that the new one will replace.
\r
72 * Can be null if this archive does not replace anything.
\r
74 public Archive getReplaced() {
\r
79 * Returns an optional new or local dependency, that is an archive that <em>this</em>
\r
80 * archive depends upon. In other words, we can only install this archive if the
\r
81 * dependency has been successfully installed. It also means we need to install the
\r
84 public ArchiveInfo getDependsOn() {
\r
89 * Returns true if this new archive is a dependency for <em>another</em> one that we
\r
92 public boolean isDependencyFor() {
\r
93 return mDependencyFor.size() > 0;
\r
97 * Adds an {@link ArchiveInfo} for which <em>this</em> package is a dependency.
\r
98 * This means the package added here depends on this package.
\r
100 public void addDependencyFor(ArchiveInfo dependencyFor) {
\r
101 if (!mDependencyFor.contains(dependencyFor)) {
\r
102 mDependencyFor.add(dependencyFor);
\r
106 public Collection<ArchiveInfo> getDependenciesFor() {
\r
107 return mDependencyFor;
\r
111 * Sets whether this archive was accepted (either manually by the user or
\r
112 * automatically if it doesn't have a license) for installation.
\r
114 public void setAccepted(boolean accepted) {
\r
115 mAccepted = accepted;
\r
119 * Returns whether this archive was accepted (either manually by the user or
\r
120 * automatically if it doesn't have a license) for installation.
\r
122 public boolean isAccepted() {
\r
127 * Sets whether this archive was rejected manually by the user.
\r
128 * An archive can neither accepted nor rejected.
\r
130 public void setRejected(boolean rejected) {
\r
131 mRejected = rejected;
\r
135 * Returns whether this archive was rejected manually by the user.
\r
136 * An archive can neither accepted nor rejected.
\r
138 public boolean isRejected() {
\r