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 com.android.sdklib.internal.repository.SdkSource; 21 22 import java.io.InputStream; 23 24 /** 25 * Public constants for the sdk-repository XML Schema. 26 */ 27 public class SdkRepoConstants extends RepoConstants { 28 29 /** The latest version of the sdk-repository XML Schema. 30 * Valid version numbers are between 1 and this number, included. */ 31 public static final int NS_LATEST_VERSION = 5; 32 33 /** The URL of the official Google sdk-repository site. */ 34 public static final String URL_GOOGLE_SDK_SITE = 35 "https://dl-ssl.google.com/android/repository/"; //$NON-NLS-1$ 36 37 /** The default name looked for by {@link SdkSource} when trying to load an 38 * sdk-repository XML if the URL doesn't match an existing resource. */ 39 public static final String URL_DEFAULT_FILENAME = "repository.xml"; //$NON-NLS-1$ 40 41 /** The pattern name looked by {@link SdkSource} when trying to load 42 * the latest sdk-repository XML that is specific to the current XSD 43 * schema revision. 44 */ 45 public static final String URL_DEFAULT_FILENAME2 = 46 String.format("repository-%d.xml", NS_LATEST_VERSION); //$NON-NLS-1$ 47 48 /** The base of our sdk-repository XML namespace. */ 49 private static final String NS_BASE = 50 "http://schemas.android.com/sdk/android/repository/"; //$NON-NLS-1$ 51 52 /** 53 * The pattern of our sdk-repository XML namespace. 54 * Matcher's group(1) is the schema version (integer). 55 */ 56 public static final String NS_PATTERN = NS_BASE + "([1-9][0-9]*)"; //$NON-NLS-1$ 57 58 /** The XML namespace of the latest sdk-repository XML. */ 59 public static final String NS_URI = getSchemaUri(NS_LATEST_VERSION); 60 61 /** The root sdk-repository element */ 62 public static final String NODE_SDK_REPOSITORY = "sdk-repository"; //$NON-NLS-1$ 63 64 /** A platform package. */ 65 public static final String NODE_PLATFORM = "platform"; //$NON-NLS-1$ 66 /** A tool package. */ 67 public static final String NODE_TOOL = "tool"; //$NON-NLS-1$ 68 /** A platform-tool package. */ 69 public static final String NODE_PLATFORM_TOOL = "platform-tool"; //$NON-NLS-1$ 70 /** A doc package. */ 71 public static final String NODE_DOC = "doc"; //$NON-NLS-1$ 72 /** A sample package. */ 73 public static final String NODE_SAMPLE = "sample"; //$NON-NLS-1$ 74 /** A system-image package. */ 75 public static final String NODE_SYSTEM_IMAGE = "system-image"; //$NON-NLS-1$ 76 /** A source package. */ 77 public static final String NODE_SOURCE = "source"; //$NON-NLS-1$ 78 79 /* An included-ABI element for a system-image package. */ 80 public static final String NODE_ABI_INCLUDED = "included-abi"; //$NON-NLS-1$ 81 /* An ABI element for a system-image package. */ 82 public static final String NODE_ABI = "abi"; //$NON-NLS-1$ 83 84 85 /** 86 * List of possible nodes in a repository XML. Used to populate options automatically 87 * in the no-GUI mode. 88 */ 89 public static final String[] NODES = { 90 NODE_PLATFORM, 91 NODE_SYSTEM_IMAGE, 92 NODE_TOOL, 93 NODE_PLATFORM_TOOL, 94 NODE_DOC, 95 NODE_SAMPLE, 96 NODE_EXTRA, 97 NODE_SOURCE, 98 }; 99 100 /** 101 * Returns a stream to the requested {@code sdk-repository} XML Schema. 102 * 103 * @param version Between 1 and {@link #NS_LATEST_VERSION}, included. 104 * @return An {@link InputStream} object for the local XSD file or 105 * null if there is no schema for the requested version. 106 */ 107 public static InputStream getXsdStream(int version) { 108 return getXsdStream(NODE_SDK_REPOSITORY, version); 109 } 110 111 /** 112 * Returns the URI of the SDK Repository schema for the given version number. 113 * @param version Between 1 and {@link #NS_LATEST_VERSION} included. 114 */ 115 public static String getSchemaUri(int version) { 116 return String.format(NS_BASE + "%d", version); //$NON-NLS-1$ 117 } 118 } 119