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