• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.xml;
18 
19 /**
20  * Helper and Constants for the AndroidManifest.xml file.
21  *
22  */
23 public final class AndroidManifest {
24 
25     public final static String NODE_MANIFEST = "manifest"; //$NON-NLS-1$
26     public final static String NODE_APPLICATION = "application"; //$NON-NLS-1$
27     public final static String NODE_ACTIVITY = "activity"; //$NON-NLS-1$
28     public final static String NODE_SERVICE = "service"; //$NON-NLS-1$
29     public final static String NODE_RECEIVER = "receiver"; //$NON-NLS-1$
30     public final static String NODE_PROVIDER = "provider"; //$NON-NLS-1$
31     public final static String NODE_INTENT = "intent-filter"; //$NON-NLS-1$
32     public final static String NODE_ACTION = "action"; //$NON-NLS-1$
33     public final static String NODE_CATEGORY = "category"; //$NON-NLS-1$
34     public final static String NODE_USES_SDK = "uses-sdk"; //$NON-NLS-1$
35     public final static String NODE_INSTRUMENTATION = "instrumentation"; //$NON-NLS-1$
36     public final static String NODE_USES_LIBRARY = "uses-library"; //$NON-NLS-1$
37 
38     public final static String ATTRIBUTE_PACKAGE = "package"; //$NON-NLS-1$
39     public final static String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$
40     public final static String ATTRIBUTE_PROCESS = "process"; //$NON-NLS-$
41     public final static String ATTRIBUTE_DEBUGGABLE = "debuggable"; //$NON-NLS-$
42     public final static String ATTRIBUTE_MIN_SDK_VERSION = "minSdkVersion"; //$NON-NLS-$
43     public final static String ATTRIBUTE_TARGET_PACKAGE = "targetPackage"; //$NON-NLS-1$
44     public final static String ATTRIBUTE_EXPORTED = "exported"; //$NON-NLS-1$
45 
46 
47     /**
48      * Combines a java package, with a class value from the manifest to make a fully qualified
49      * class name
50      * @param javaPackage the java package from the manifest.
51      * @param className the class name from the manifest.
52      * @return the fully qualified class name.
53      */
combinePackageAndClassName(String javaPackage, String className)54     public static String combinePackageAndClassName(String javaPackage, String className) {
55         if (className == null || className.length() == 0) {
56             return javaPackage;
57         }
58         if (javaPackage == null || javaPackage.length() == 0) {
59             return className;
60         }
61 
62         // the class name can be a subpackage (starts with a '.'
63         // char), a simple class name (no dot), or a full java package
64         boolean startWithDot = (className.charAt(0) == '.');
65         boolean hasDot = (className.indexOf('.') != -1);
66         if (startWithDot || hasDot == false) {
67 
68             // add the concatenation of the package and class name
69             if (startWithDot) {
70                 return javaPackage + className;
71             } else {
72                 return javaPackage + '.' + className;
73             }
74         } else {
75             // just add the class as it should be a fully qualified java name.
76             return className;
77         }
78     }
79 
80 }
81