FileDocCategorySizeDatePackage
AndroidTargetData.javaAPI DocAndroid 1.5 API12869Wed May 06 22:41:10 BST 2009com.android.ide.eclipse.adt.sdk

AndroidTargetData

public class AndroidTargetData extends Object
This class contains the data of an Android Target as loaded from the SDK.

Fields Summary
public static final int
DESCRIPTOR_MANIFEST
public static final int
DESCRIPTOR_LAYOUT
public static final int
DESCRIPTOR_MENU
public static final int
DESCRIPTOR_XML
public static final int
DESCRIPTOR_RESOURCES
public static final int
DESCRIPTOR_SEARCHABLE
public static final int
DESCRIPTOR_PREFERENCES
public static final int
DESCRIPTOR_APPWIDGET_PROVIDER
private final com.android.sdklib.IAndroidTarget
mTarget
private com.android.ide.eclipse.adt.build.DexWrapper
mDexWrapper
private Hashtable
mAttributeValues
mAttributeValues is a map { key => list [ values ] }. The key for the map is "(element-xml-name,attribute-namespace:attribute-xml-local-name)". The attribute namespace prefix must be: - "android" for AndroidConstants.NS_RESOURCES - "xmlns" for the XMLNS URI. This is used for attributes that do not have a unique name, but still need to be populated with values in the UI. Uniquely named attributes have their values in {@link #mEnumValueMap}.
private com.android.ide.eclipse.common.resources.IResourceRepository
mSystemResourceRepository
private com.android.ide.eclipse.editors.manifest.descriptors.AndroidManifestDescriptors
mManifestDescriptors
private com.android.ide.eclipse.editors.layout.descriptors.LayoutDescriptors
mLayoutDescriptors
private com.android.ide.eclipse.editors.menu.descriptors.MenuDescriptors
mMenuDescriptors
private com.android.ide.eclipse.editors.xml.descriptors.XmlDescriptors
mXmlDescriptors
private Map
mEnumValueMap
private com.android.ide.eclipse.editors.resources.manager.ProjectResources
mFrameworkResources
private LayoutBridge
mLayoutBridge
private boolean
mLayoutBridgeInit
Constructors Summary
AndroidTargetData(com.android.sdklib.IAndroidTarget androidTarget)


      
        mTarget = androidTarget;
    
Methods Summary
public java.lang.String[]getAttributeValues(java.lang.String elementName, java.lang.String attributeName)
Returns this list of possible values for an XML attribute.

This should only be called for attributes for which possible values depend on the parent element node.

For attributes that have the same values no matter the parent node, use {@link #getEnumValueMap()}.

param
elementName the name of the element containing the attribute.
param
attributeName the name of the attribute
return
an array of String with the possible values, or null if no values were found.

        String key = String.format("(%1$s,%2$s)", elementName, attributeName); //$NON-NLS-1$
        return mAttributeValues.get(key);
    
public java.lang.String[]getAttributeValues(java.lang.String elementName, java.lang.String attributeName, java.lang.String greatGrandParentElementName)
Returns this list of possible values for an XML attribute.

This should only be called for attributes for which possible values depend on the parent and great-grand-parent element node.

The typical example of this is for the 'name' attribute under activity/intent-filter/action

For attributes that have the same values no matter the parent node, use {@link #getEnumValueMap()}.

param
elementName the name of the element containing the attribute.
param
attributeName the name of the attribute
param
greatGrandParentElementName the great-grand-parent node.
return
an array of String with the possible values, or null if no values were found.

        if (greatGrandParentElementName != null) {
            String key = String.format("(%1$s,%2$s,%3$s)", //$NON-NLS-1$
                    greatGrandParentElementName, elementName, attributeName); 
            String[] values = mAttributeValues.get(key);
            if (values != null) {
                return values;
            }
        }
        
        return getAttributeValues(elementName, attributeName);
    
public com.android.ide.eclipse.editors.descriptors.IDescriptorProvidergetDescriptorProvider(int descriptorId)
Returns an {@link IDescriptorProvider} from a given Id. The Id can be one of {@link #DESCRIPTOR_MANIFEST}, {@link #DESCRIPTOR_LAYOUT}, {@link #DESCRIPTOR_MENU}, or {@link #DESCRIPTOR_XML}. All other values will throw an {@link IllegalArgumentException}.

        switch (descriptorId) {
            case DESCRIPTOR_MANIFEST:
                return mManifestDescriptors;
            case DESCRIPTOR_LAYOUT:
                return mLayoutDescriptors;
            case DESCRIPTOR_MENU:
                return mMenuDescriptors;
            case DESCRIPTOR_XML:
                return mXmlDescriptors;
            case DESCRIPTOR_RESOURCES:
                // FIXME: since it's hard-coded the Resources Descriptors are not platform dependent.
                return ResourcesDescriptors.getInstance();
            case DESCRIPTOR_PREFERENCES:
                return mXmlDescriptors.getPreferencesProvider();
            case DESCRIPTOR_APPWIDGET_PROVIDER:
                return mXmlDescriptors.getAppWidgetProvider();
            case DESCRIPTOR_SEARCHABLE:
                return mXmlDescriptors.getSearchableProvider();
            default :
                 throw new IllegalArgumentException();
        }
    
public com.android.ide.eclipse.adt.build.DexWrappergetDexWrapper()

        return mDexWrapper;
    
public java.util.MapgetEnumValueMap()
Returns the enum values map.

The map defines the possible values for XML attributes. The key is the attribute name and the value is a map of (string, integer) in which the key (string) is the name of the value, and the Integer is the numerical value in the compiled binary XML files.

        return mEnumValueMap;
    
public com.android.ide.eclipse.editors.resources.manager.ProjectResourcesgetFrameworkResources()
Returns the {@link ProjectResources} containing the Framework Resources.

        return mFrameworkResources;
    
public synchronized com.android.ide.eclipse.adt.sdk.AndroidTargetData$LayoutBridgegetLayoutBridge()
Returns a {@link LayoutBridge} object possibly containing a {@link ILayoutBridge} object.

If {@link LayoutBridge#bridge} is null, {@link LayoutBridge#status} will contain the reason (either {@link LoadStatus#LOADING} or {@link LoadStatus#FAILED}).

Valid {@link ILayoutBridge} objects are always initialized before being returned.

        if (mLayoutBridgeInit == false && mLayoutBridge.bridge != null) {
            mLayoutBridge.bridge.init(mTarget.getPath(IAndroidTarget.FONTS),
                    getEnumValueMap());
            mLayoutBridgeInit = true;
        }
        return mLayoutBridge;
    
public com.android.ide.eclipse.editors.layout.descriptors.LayoutDescriptorsgetLayoutDescriptors()
Returns the layout Descriptors.

        return mLayoutDescriptors;
    
public com.android.ide.eclipse.editors.manifest.descriptors.AndroidManifestDescriptorsgetManifestDescriptors()
Returns the manifest descriptors.

        return mManifestDescriptors;
    
public com.android.ide.eclipse.editors.menu.descriptors.MenuDescriptorsgetMenuDescriptors()
Returns the menu descriptors.

        return mMenuDescriptors;
    
public com.android.ide.eclipse.common.resources.IResourceRepositorygetSystemResources()

        return mSystemResourceRepository;
    
public com.android.ide.eclipse.editors.xml.descriptors.XmlDescriptorsgetXmlDescriptors()
Returns the XML descriptors

        return mXmlDescriptors;
    
voidsetDexWrapper(com.android.ide.eclipse.adt.build.DexWrapper wrapper)

        mDexWrapper = wrapper;
    
voidsetExtraData(com.android.ide.eclipse.common.resources.IResourceRepository systemResourceRepository, com.android.ide.eclipse.editors.manifest.descriptors.AndroidManifestDescriptors manifestDescriptors, com.android.ide.eclipse.editors.layout.descriptors.LayoutDescriptors layoutDescriptors, com.android.ide.eclipse.editors.menu.descriptors.MenuDescriptors menuDescriptors, com.android.ide.eclipse.editors.xml.descriptors.XmlDescriptors xmlDescriptors, java.util.Map enumValueMap, java.lang.String[] permissionValues, java.lang.String[] activityIntentActionValues, java.lang.String[] broadcastIntentActionValues, java.lang.String[] serviceIntentActionValues, java.lang.String[] intentCategoryValues, com.android.sdklib.IAndroidTarget.IOptionalLibrary[] optionalLibraries, com.android.ide.eclipse.editors.resources.manager.ProjectResources resources, com.android.ide.eclipse.adt.sdk.AndroidTargetData$LayoutBridge layoutBridge)
Creates an AndroidTargetData object.

param
optionalLibraries

        
        mSystemResourceRepository = systemResourceRepository;
        mManifestDescriptors = manifestDescriptors;
        mLayoutDescriptors = layoutDescriptors;
        mMenuDescriptors = menuDescriptors;
        mXmlDescriptors = xmlDescriptors;
        mEnumValueMap = enumValueMap;
        mFrameworkResources = resources;
        mLayoutBridge = layoutBridge;

        setPermissions(permissionValues);
        setIntentFilterActionsAndCategories(activityIntentActionValues, broadcastIntentActionValues,
                serviceIntentActionValues, intentCategoryValues);
        setOptionalLibraries(optionalLibraries);
    
private voidsetIntentFilterActionsAndCategories(java.lang.String[] activityIntentActions, java.lang.String[] broadcastIntentActions, java.lang.String[] serviceIntentActions, java.lang.String[] intentCategoryValues)

        setValues("(activity,action,android:name)", activityIntentActions); //$NON-NLS-1$
        setValues("(receiver,action,android:name)", broadcastIntentActions); //$NON-NLS-1$
        setValues("(service,action,android:name)", serviceIntentActions); //$NON-NLS-1$
        setValues("(category,android:name)", intentCategoryValues); //$NON-NLS-1$
    
private voidsetOptionalLibraries(com.android.sdklib.IAndroidTarget.IOptionalLibrary[] optionalLibraries)

        String[] values;
        
        if (optionalLibraries == null) {
            values = new String[0];
        } else {
            values = new String[optionalLibraries.length];
            for (int i = 0; i < optionalLibraries.length; i++) {
                values[i] = optionalLibraries[i].getName();
            }
        }
        setValues("(uses-library,android:name)", values);
    
private voidsetPermissions(java.lang.String[] permissionValues)
Sets the permission values

param
permissionValues the list of permissions

        setValues("(uses-permission,android:name)", permissionValues); //$NON-NLS-1$
        setValues("(application,android:permission)", permissionValues); //$NON-NLS-1$
        setValues("(activity,android:permission)", permissionValues); //$NON-NLS-1$
        setValues("(receiver,android:permission)", permissionValues); //$NON-NLS-1$
        setValues("(service,android:permission)", permissionValues); //$NON-NLS-1$
        setValues("(provider,android:permission)", permissionValues); //$NON-NLS-1$
    
private voidsetValues(java.lang.String name, java.lang.String[] values)
Sets a (name, values) pair in the hash map.

If the name is already present in the map, it is first removed.

param
name the name associated with the values.
param
values The values to add.

        mAttributeValues.remove(name);
        mAttributeValues.put(name, values);