OSDN Git Service

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