• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Eclipse Public License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.eclipse.org/org/documents/epl-v10.php
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.sdklib.repository;
18 
19 
20 import java.io.InputStream;
21 
22 /**
23  * Public constants for the sdk-repository XML Schema.
24  */
25 public class SdkRepository {
26 
27     /** The URL of the official Google sdk-repository site. */
28     public static final String URL_GOOGLE_SDK_REPO_SITE =
29         "https://dl-ssl.google.com/android/repository/";                        //$NON-NLS-1$
30 
31     public static final String URL_DEFAULT_XML_FILE = "repository.xml";         //$NON-NLS-1$
32 
33     /** The base of our XML namespace. */
34     private static final String NS_SDK_REPOSITORY_BASE =
35         "http://schemas.android.com/sdk/android/repository/";                   //$NON-NLS-1$
36 
37     /** The pattern of our XML namespace. */
38     public static final String NS_SDK_REPOSITORY_PATTERN =
39         NS_SDK_REPOSITORY_BASE + "[1-9][0-9]*";        //$NON-NLS-1$
40 
41     /** The latest version of the sdk-repository XML Schema.
42      *  Valid version numbers are between 1 and this number, included. */
43     public static final int NS_LATEST_VERSION = 1;
44 
45     /** The XML namespace of the latest sdk-repository XML. */
46     public static final String NS_SDK_REPOSITORY = getSchemaUri(NS_LATEST_VERSION);
47 
48     /** The root sdk-repository element */
49     public static final String NODE_SDK_REPOSITORY = "sdk-repository";          //$NON-NLS-1$
50 
51     /** A platform package. */
52     public static final String NODE_PLATFORM = "platform";                      //$NON-NLS-1$
53     /** An add-on package. */
54     public static final String NODE_ADD_ON   = "add-on";                        //$NON-NLS-1$
55     /** A tool package. */
56     public static final String NODE_TOOL     = "tool";                          //$NON-NLS-1$
57     /** A doc package. */
58     public static final String NODE_DOC      = "doc";                           //$NON-NLS-1$
59     /** An extra package. */
60     public static final String NODE_EXTRA    = "extra";                         //$NON-NLS-1$
61 
62     /** The license definition. */
63     public static final String NODE_LICENSE       = "license";                  //$NON-NLS-1$
64     /** The optional uses-license for all packages (platform, add-on, tool, doc) or for a lib. */
65     public static final String NODE_USES_LICENSE  = "uses-license";             //$NON-NLS-1$
66     /** The revision, an int > 0, for all packages (platform, add-on, tool, doc). */
67     public static final String NODE_REVISION      = "revision";                 //$NON-NLS-1$
68     /** The optional description for all packages (platform, add-on, tool, doc) or for a lib. */
69     public static final String NODE_DESCRIPTION   = "description";              //$NON-NLS-1$
70     /** The optional description URL for all packages (platform, add-on, tool, doc). */
71     public static final String NODE_DESC_URL      = "desc-url";                 //$NON-NLS-1$
72     /** The optional release note for all packages (platform, add-on, tool, doc). */
73     public static final String NODE_RELEASE_NOTE  = "release-note";             //$NON-NLS-1$
74     /** The optional release note URL for all packages (platform, add-on, tool, doc). */
75     public static final String NODE_RELEASE_URL   = "release-url";              //$NON-NLS-1$
76     /** The optional minimal tools revision required by platform & extra packages. */
77     public static final String NODE_MIN_TOOLS_REV = "min-tools-rev";            //$NON-NLS-1$
78 
79     /** The version, a string, for platform packages. */
80     public static final String NODE_VERSION   = "version";                      //$NON-NLS-1$
81     /** The api-level, an int > 0, for platform, add-on and doc packages. */
82     public static final String NODE_API_LEVEL = "api-level";                    //$NON-NLS-1$
83     /** The codename, a string, for platform packages. */
84     public static final String NODE_CODENAME = "codename";                      //$NON-NLS-1$
85     /** The vendor, a string, for add-on packages. */
86     public static final String NODE_VENDOR    = "vendor";                       //$NON-NLS-1$
87     /** The name, a string, for add-on packages or for libraries. */
88     public static final String NODE_NAME      = "name";                         //$NON-NLS-1$
89 
90     /** The libs container, optional for an add-on. */
91     public static final String NODE_LIBS      = "libs";                         //$NON-NLS-1$
92     /** A lib element in a libs container. */
93     public static final String NODE_LIB       = "lib";                          //$NON-NLS-1$
94 
95     /** The path, a string, for extra packages. */
96     public static final String NODE_PATH = "path";                              //$NON-NLS-1$
97 
98     /** The archives container, for all packages. */
99     public static final String NODE_ARCHIVES = "archives";                      //$NON-NLS-1$
100     /** An archive element, for the archives container. */
101     public static final String NODE_ARCHIVE  = "archive";                       //$NON-NLS-1$
102 
103     /** An archive size, an int > 0. */
104     public static final String NODE_SIZE     = "size";                          //$NON-NLS-1$
105     /** A sha1 archive checksum, as a 40-char hex. */
106     public static final String NODE_CHECKSUM = "checksum";                      //$NON-NLS-1$
107     /** A download archive URL, either absolute or relative to the repository xml. */
108     public static final String NODE_URL      = "url";                           //$NON-NLS-1$
109 
110     /** An archive checksum type, mandatory. */
111     public static final String ATTR_TYPE = "type";                              //$NON-NLS-1$
112     /** An archive OS attribute, mandatory. */
113     public static final String ATTR_OS   = "os";                                //$NON-NLS-1$
114     /** An optional archive Architecture attribute. */
115     public static final String ATTR_ARCH = "arch";                              //$NON-NLS-1$
116 
117     /** A license definition ID. */
118     public static final String ATTR_ID = "id";                                  //$NON-NLS-1$
119     /** A license reference. */
120     public static final String ATTR_REF = "ref";                                //$NON-NLS-1$
121 
122     /** Type of a sha1 checksum. */
123     public static final String SHA1_TYPE = "sha1";                              //$NON-NLS-1$
124 
125     /** Length of a string representing a SHA1 checksum; always 40 characters long. */
126     public static final int SHA1_CHECKSUM_LEN = 40;
127 
128 
129     /**
130      * Returns a stream to the requested repository XML Schema.
131      *
132      * @param version Between 1 and {@link #NS_LATEST_VERSION}, included.
133      * @return An {@link InputStream} object for the local XSD file or
134      *         null if there is no schema for the requested version.
135      */
getXsdStream(int version)136     public static InputStream getXsdStream(int version) {
137         String filename = String.format("sdk-repository-%d.xsd", version);      //$NON-NLS-1$
138         return SdkRepository.class.getResourceAsStream(filename);
139     }
140 
141     /**
142      * Returns the URI of the SDK Repository schema for the given version number.
143      * @param version Between 1 and {@link #NS_LATEST_VERSION} included.
144      */
getSchemaUri(int version)145     public static String getSchemaUri(int version) {
146         return String.format(NS_SDK_REPOSITORY_BASE + "%d", version);           //$NON-NLS-1$
147     }
148 
149 }
150