1 /* 2 * Copyright (C) 2010 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-addons-list XML Schema. 24 */ 25 public class SdkAddonsListConstants { 26 27 /** The URL where to find the official addons list fle. */ 28 public static final String URL_ADDON_LIST = 29 "https://dl-ssl.google.com/android/repository/addons_list.xml"; //$NON-NLS-1$ 30 31 /** The canonical URL filename for addons-list XML files. */ 32 public static final String URL_DEFAULT_FILENAME = "addons_list.xml"; //$NON-NLS-1$ 33 34 /** The base of our sdk-addons-list XML namespace. */ 35 private static final String NS_BASE = 36 "http://schemas.android.com/sdk/android/addons-list/"; //$NON-NLS-1$ 37 38 /** 39 * The pattern of our sdk-addons-list XML namespace. 40 * Matcher's group(1) is the schema version (integer). 41 */ 42 public static final String NS_PATTERN = NS_BASE + "([1-9][0-9]*)"; //$NON-NLS-1$ 43 44 /** The latest version of the sdk-addons-list XML Schema. 45 * Valid version numbers are between 1 and this number, included. */ 46 public static final int NS_LATEST_VERSION = 1; 47 48 /** The XML namespace of the latest sdk-addons-list XML. */ 49 public static final String NS_URI = getSchemaUri(NS_LATEST_VERSION); 50 51 /** The root sdk-addons-list element */ 52 public static final String NODE_SDK_ADDONS_LIST = "sdk-addons-list"; //$NON-NLS-1$ 53 54 /** An add-on site. */ 55 public static final String NODE_ADDON_SITE = "addon-site"; //$NON-NLS-1$ 56 57 /** The UI-visible name of the add-on site. */ 58 public static final String NODE_NAME = "name"; //$NON-NLS-1$ 59 60 /** 61 * The URL of the site. 62 * <p/> 63 * This can be either the exact URL of the an XML resource conforming 64 * to the latest sdk-addon-N.xsd schema, or it can be the URL of a 65 * 'directory', in which case the manager will look for a resource 66 * named 'addon.xml' at this location. 67 * <p/> 68 * Examples: 69 * <pre> 70 * http://www.example.com/android/my_addons.xml 71 * or 72 * http://www.example.com/android/ 73 * </pre> 74 * In the second example, the manager will actually look for 75 * http://www.example.com/android/addon.xml 76 */ 77 public static final String NODE_URL = "url"; //$NON-NLS-1$ 78 79 /** 80 * Returns a stream to the requested sdk-addon XML Schema. 81 * 82 * @param version Between 1 and {@link #NS_LATEST_VERSION}, included. 83 * @return An {@link InputStream} object for the local XSD file or 84 * null if there is no schema for the requested version. 85 */ 86 public static InputStream getXsdStream(int version) { 87 String filename = String.format("sdk-addons-list-%d.xsd", version); //$NON-NLS-1$ 88 return SdkAddonsListConstants.class.getResourceAsStream(filename); 89 } 90 91 /** 92 * Returns the URI of the sdk-addon schema for the given version number. 93 * @param version Between 1 and {@link #NS_LATEST_VERSION} included. 94 */ 95 public static String getSchemaUri(int version) { 96 return String.format(NS_BASE + "%d", version); //$NON-NLS-1$ 97 } 98 } 99