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 com.android.sdklib.internal.repository.SdkSource; 21 22 import java.io.InputStream; 23 24 /** 25 * Public constants for the sdk-addon XML Schema. 26 */ 27 public class SdkAddonConstants extends RepoConstants { 28 29 /** The default name looked for by {@link SdkSource} when trying to load an 30 * sdk-addon XML if the URL doesn't match an existing resource. */ 31 public static final String URL_DEFAULT_FILENAME = "addon.xml"; //$NON-NLS-1$ 32 33 /** The base of our sdk-addon XML namespace. */ 34 private static final String NS_BASE = 35 "http://schemas.android.com/sdk/android/addon/"; //$NON-NLS-1$ 36 37 /** 38 * The pattern of our sdk-addon XML namespace. 39 * Matcher's group(1) is the schema version (integer). 40 */ 41 public static final String NS_PATTERN = NS_BASE + "([1-9][0-9]*)"; //$NON-NLS-1$ 42 43 /** The latest version of the sdk-addon XML Schema. 44 * Valid version numbers are between 1 and this number, included. */ 45 public static final int NS_LATEST_VERSION = 3; 46 47 /** The XML namespace of the latest sdk-addon XML. */ 48 public static final String NS_URI = getSchemaUri(NS_LATEST_VERSION); 49 50 /** The root sdk-addon element */ 51 public static final String NODE_SDK_ADDON = "sdk-addon"; //$NON-NLS-1$ 52 53 /** An add-on package. */ 54 public static final String NODE_ADD_ON = "add-on"; //$NON-NLS-1$ 55 56 /** 57 * List of possible nodes in a repository XML. Used to populate options automatically 58 * in the no-GUI mode. 59 */ 60 public static final String[] NODES = { 61 NODE_ADD_ON, 62 NODE_EXTRA 63 }; 64 65 /** 66 * Returns a stream to the requested {@code sdk-addon} XML Schema. 67 * 68 * @param version Between 1 and {@link #NS_LATEST_VERSION}, included. 69 * @return An {@link InputStream} object for the local XSD file or 70 * null if there is no schema for the requested version. 71 */ 72 public static InputStream getXsdStream(int version) { 73 return getXsdStream(NODE_SDK_ADDON, version); 74 } 75 76 /** 77 * Returns the URI of the sdk-addon schema for the given version number. 78 * @param version Between 1 and {@link #NS_LATEST_VERSION} included. 79 */ 80 public static String getSchemaUri(int version) { 81 return String.format(NS_BASE + "%d", version); //$NON-NLS-1$ 82 } 83 } 84