1 /* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 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.internal.repository; 18 19 import com.android.annotations.Nullable; 20 import com.android.sdklib.repository.SdkAddonConstants; 21 22 import org.w3c.dom.Document; 23 24 import java.io.InputStream; 25 26 27 /** 28 * An sdk-addon source, i.e. a download site for addons and extra packages. 29 * A repository describes one or more {@link Package}s available for download. 30 */ 31 public class SdkAddonSource extends SdkSource { 32 33 /** 34 * Constructs a new source for the given repository URL. 35 * @param url The source URL. Cannot be null. If the URL ends with a /, the default 36 * repository.xml filename will be appended automatically. 37 * @param uiName The UI-visible name of the source. Can be null. 38 */ 39 public SdkAddonSource(String url, String uiName) { 40 super(url, uiName); 41 } 42 43 /** 44 * Returns true if this is an addon source. 45 * We only load addons and extras from these sources. 46 */ 47 @Override 48 public boolean isAddonSource() { 49 return true; 50 } 51 52 @Override 53 protected String[] getDefaultXmlFileUrls() { 54 return new String[] { SdkAddonConstants.URL_DEFAULT_FILENAME }; 55 } 56 57 @Override 58 protected int getNsLatestVersion() { 59 return SdkAddonConstants.NS_LATEST_VERSION; 60 } 61 62 @Override 63 protected String getNsUri() { 64 return SdkAddonConstants.NS_URI; 65 } 66 67 @Override 68 protected String getNsPattern() { 69 return SdkAddonConstants.NS_PATTERN; 70 } 71 72 @Override 73 protected String getSchemaUri(int version) { 74 return SdkAddonConstants.getSchemaUri(version); 75 } 76 77 @Override 78 protected String getRootElementName() { 79 return SdkAddonConstants.NODE_SDK_ADDON; 80 } 81 82 @Override 83 protected InputStream getXsdStream(int version) { 84 return SdkAddonConstants.getXsdStream(version); 85 } 86 87 /** 88 * There is no support forward evolution of the sdk-addon schema yet since we 89 * currently have only one version. 90 * 91 * @param xml The input XML stream. Can be null. 92 * @return Always null. 93 * @null This implementation always return null. 94 */ 95 @Override 96 protected Document findAlternateToolsXml(@Nullable InputStream xml) { 97 return null; 98 } 99 } 100