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.sdklib.internal.repository;
\r
19 import com.android.sdklib.internal.repository.Archive.Arch;
\r
20 import com.android.sdklib.internal.repository.Archive.Os;
\r
21 import com.android.sdklib.repository.SdkRepoConstants;
\r
23 import org.w3c.dom.Node;
\r
25 import java.util.Map;
\r
26 import java.util.Properties;
\r
29 * Represents an XML node in an SDK repository that has a min-tools-rev requirement.
\r
31 public abstract class MinToolsPackage extends Package implements IMinToolsDependency {
\r
33 static final String PROP_MIN_TOOLS_REV = "Platform.MinToolsRev"; //$NON-NLS-1$
\r
36 * The minimal revision of the tools package required by this extra package, if > 0,
\r
37 * or {@link #MIN_TOOLS_REV_NOT_SPECIFIED} if there is no such requirement.
\r
39 private final int mMinToolsRevision;
\r
42 * Creates a new package from the attributes and elements of the given XML node.
\r
43 * This constructor should throw an exception if the package cannot be created.
\r
45 * @param source The {@link SdkSource} where this is loaded from.
\r
46 * @param packageNode The XML element being parsed.
\r
47 * @param nsUri The namespace URI of the originating XML document, to be able to deal with
\r
48 * parameters that vary according to the originating XML schema.
\r
49 * @param licenses The licenses loaded from the XML originating document.
\r
51 MinToolsPackage(SdkSource source, Node packageNode, String nsUri, Map<String,String> licenses) {
\r
52 super(source, packageNode, nsUri, licenses);
\r
54 mMinToolsRevision = XmlParserUtils.getXmlInt(packageNode,
\r
55 SdkRepoConstants.NODE_MIN_TOOLS_REV,
\r
56 MIN_TOOLS_REV_NOT_SPECIFIED);
\r
60 * Manually create a new package with one archive and the given attributes.
\r
61 * This is used to create packages from local directories in which case there must be
\r
62 * one archive which URL is the actual target location.
\r
64 * Properties from props are used first when possible, e.g. if props is non null.
\r
66 * By design, this creates a package with one and only one archive.
\r
68 public MinToolsPackage(
\r
77 String archiveOsPath) {
\r
78 super(source, props, revision, license, description, descUrl,
\r
79 archiveOs, archiveArch, archiveOsPath);
\r
81 mMinToolsRevision = Integer.parseInt(
\r
82 getProperty(props, PROP_MIN_TOOLS_REV, Integer.toString(MIN_TOOLS_REV_NOT_SPECIFIED)));
\r
86 * The minimal revision of the tools package required by this extra package, if > 0,
\r
87 * or {@link #MIN_TOOLS_REV_NOT_SPECIFIED} if there is no such requirement.
\r
89 public int getMinToolsRevision() {
\r
90 return mMinToolsRevision;
\r
94 void saveProperties(Properties props) {
\r
95 super.saveProperties(props);
\r
97 if (getMinToolsRevision() != MIN_TOOLS_REV_NOT_SPECIFIED) {
\r
98 props.setProperty(PROP_MIN_TOOLS_REV, Integer.toString(getMinToolsRevision()));
\r