blob: 265826c0d66985576906b5120cb1a347d8712b8b [file] [log] [blame]
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.tools.idea.sdk.remote.internal.sources;
import com.android.annotations.Nullable;
import org.w3c.dom.Document;
import javax.xml.transform.stream.StreamSource;
import java.io.InputStream;
/**
* An sdk-addon source, i.e. a download site for addons and extra packages.
* A repository describes one or more {@link RemotePkgInfo}s available for download.
*/
public class SdkAddonSource extends SdkSource {
/**
* Constructs a new source for the given repository URL.
*
* @param url The source URL. Cannot be null. If the URL ends with a /, the default
* addon.xml filename will be appended automatically.
* @param uiName The UI-visible name of the source. Can be null.
*/
public SdkAddonSource(String url, String uiName) {
super(url, uiName);
}
/**
* Returns true if this is an addon source.
* We only load addons and extras from these sources.
*/
@Override
public boolean isAddonSource() {
return true;
}
/**
* Returns true if this is a system-image source.
* We only load system-images from these sources.
*/
@Override
public boolean isSysImgSource() {
return false;
}
@Override
protected String[] getDefaultXmlFileUrls() {
return new String[]{SdkAddonConstants.URL_DEFAULT_FILENAME};
}
@Override
protected int getNsLatestVersion() {
return SdkAddonConstants.NS_LATEST_VERSION;
}
@Override
protected String getNsUri() {
return SdkAddonConstants.NS_URI;
}
@Override
protected String getNsPattern() {
return SdkAddonConstants.NS_PATTERN;
}
@Override
protected String getSchemaUri(int version) {
return SdkAddonConstants.getSchemaUri(version);
}
@Override
protected String getRootElementName() {
return SdkAddonConstants.NODE_SDK_ADDON;
}
@Override
protected StreamSource[] getXsdStream(int version) {
return SdkAddonConstants.getXsdStream(version);
}
/**
* This kind of schema does not support forward-evolution of the <tool> element.
*
* @param xml The input XML stream. Can be null.
* @return Always null.
* @null This implementation always return null.
*/
@Override
protected Document findAlternateToolsXml(@Nullable InputStream xml) {
return null;
}
}