1 /* 2 * Copyright (C) 2011 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.tools.lint.client.api; 18 19 import com.android.annotations.NonNull; 20 import com.android.annotations.Nullable; 21 import com.google.common.annotations.Beta; 22 23 /** 24 * Information about SDKs 25 * <p> 26 * <b>NOTE: This is not a public or final API; if you rely on this be prepared 27 * to adjust your code for the next tools release.</b> 28 */ 29 @Beta 30 public abstract class SdkInfo { 31 /** 32 * Returns true if the given child view is the same class or a sub class of 33 * the given parent view class 34 * 35 * @param parentViewFqcn the fully qualified class name of the parent view 36 * @param childViewFqcn the fully qualified class name of the child view 37 * @return true if the child view is a sub view of (or the same class as) 38 * the parent view 39 */ 40 public boolean isSubViewOf(@NonNull String parentViewFqcn, @NonNull String childViewFqcn) { 41 while (!childViewFqcn.equals("android.view.View")) { //$NON-NLS-1$ 42 if (parentViewFqcn.equals(childViewFqcn)) { 43 return true; 44 } 45 childViewFqcn = getParentViewClass(childViewFqcn); 46 if (childViewFqcn == null) { 47 // Unknown view - err on the side of caution 48 return true; 49 } 50 } 51 52 return false; 53 } 54 55 56 /** 57 * Returns the fully qualified name of the parent view, or null if the view 58 * is the root android.view.View class. 59 * 60 * @param fqcn the fully qualified class name of the view 61 * @return the fully qualified class name of the parent view, or null 62 */ 63 @Nullable 64 public abstract String getParentViewClass(@NonNull String fqcn); 65 66 /** 67 * Returns the class name of the parent view, or null if the view is the 68 * root android.view.View class. This is the same as the 69 * {@link #getParentViewClass(String)} but without the package. 70 * 71 * @param name the view class name to look up the parent for (not including 72 * package) 73 * @return the view name of the parent 74 */ 75 @Nullable 76 public abstract String getParentViewName(@NonNull String name); 77 78 // TODO: Add access to resource resolution here. 79 } 80