public abstract class AbstractResourceRepository
extends java.lang.Object
ResourceTable that:
ITEM_MAP_LOCK object.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.Object |
ITEM_MAP_LOCK
The lock used to protect map access.
|
| Constructor and Description |
|---|
AbstractResourceRepository() |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<ResourceItem> |
getAllResourceItems() |
java.util.List<com.android.resources.ResourceType> |
getAvailableResourceTypes() |
com.google.common.collect.Table<com.android.ide.common.rendering.api.ResourceNamespace,com.android.resources.ResourceType,ResourceValueMap> |
getConfiguredResources(FolderConfiguration referenceConfig)
Returns the resources values matching a given
FolderConfiguration. |
ResourceValueMap |
getConfiguredResources(com.android.ide.common.rendering.api.ResourceNamespace namespace,
com.android.resources.ResourceType type,
FolderConfiguration referenceConfig)
Returns a map of (resource name, resource value) for the given
ResourceType. |
com.android.ide.common.rendering.api.ResourceValue |
getConfiguredValue(com.android.resources.ResourceType type,
java.lang.String name,
FolderConfiguration referenceConfig) |
protected abstract ResourceTable |
getFullTable()
Returns the fully computed
ResourceTable for this repository. |
ResourceTable |
getItems() |
java.util.Collection<java.lang.String> |
getItemsOfType(com.android.ide.common.rendering.api.ResourceNamespace namespace,
com.android.resources.ResourceType type) |
java.util.Collection<java.lang.String> |
getItemsOfType(com.android.resources.ResourceType type) |
java.util.SortedSet<java.lang.String> |
getLanguages()
Returns the sorted list of languages used in the resources.
|
java.util.SortedSet<LocaleQualifier> |
getLocales()
Returns the sorted list of languages used in the resources.
|
protected com.google.common.collect.ListMultimap<java.lang.String,ResourceItem> |
getMap(com.android.ide.common.rendering.api.ResourceNamespace namespace,
com.android.resources.ResourceType type) |
protected abstract com.google.common.collect.ListMultimap<java.lang.String,ResourceItem> |
getMap(com.android.ide.common.rendering.api.ResourceNamespace namespace,
com.android.resources.ResourceType type,
boolean create) |
ResourceFile |
getMatchingFile(java.lang.String name,
com.android.resources.ResourceType type,
FolderConfiguration config)
Returns the
ResourceFile matching the given name, ResourceType and
configuration. |
java.util.List<ResourceFile> |
getMatchingFiles(java.lang.String name,
com.android.resources.ResourceType type,
FolderConfiguration config)
Returns a list of
ResourceFile matching the given name, ResourceType and
configuration. |
abstract java.util.Set<com.android.ide.common.rendering.api.ResourceNamespace> |
getNamespaces() |
java.util.SortedSet<java.lang.String> |
getRegions(java.lang.String currentLanguage)
Returns the sorted list of regions used in the resources with the given language.
|
java.util.List<ResourceItem> |
getResourceItem(com.android.resources.ResourceType resourceType,
java.lang.String resourceName)
Deprecated.
|
java.util.List<ResourceItem> |
getResourceItems(com.android.ide.common.rendering.api.ResourceNamespace namespace,
com.android.resources.ResourceType resourceType,
java.lang.String resourceName) |
boolean |
hasResourceItem(com.android.resources.ResourceType resourceType,
java.lang.String resourceName)
Returns true if this resource repository contains a resource of the given name.
|
boolean |
hasResourceItem(java.lang.String url)
Returns true if this resource repository contains a resource of the given
name.
|
boolean |
hasResourcesOfType(com.android.resources.ResourceType resourceType)
Returns whether the repository has resources of a given
ResourceType. |
boolean |
isFramework()
Deprecated.
|
public static final java.lang.Object ITEM_MAP_LOCK
In the IDE, this needs to be obtained AFTER the IDE read/write lock, to avoid deadlocks (most readers of the repository system execute in a read action, so obtaining the locks in opposite order results in deadlocks).
@Deprecated public final boolean isFramework()
AbstractResourceRepository for framework resources, but
eventually we will start at which point a single repository may contain both framework and
app resources. The "truth" lies in the namespace of the ResourceItems. Soon we'll get
rid of this method.@NonNull @GuardedBy(value="AbstractResourceRepository.ITEM_MAP_LOCK") protected abstract ResourceTable getFullTable()
ResourceTable for this repository.
The returned object should be accessed only while holding ITEM_MAP_LOCK.
@Nullable @GuardedBy(value="AbstractResourceRepository.ITEM_MAP_LOCK") protected abstract com.google.common.collect.ListMultimap<java.lang.String,ResourceItem> getMap(@NonNull com.android.ide.common.rendering.api.ResourceNamespace namespace, @NonNull com.android.resources.ResourceType type, boolean create)
@NonNull @GuardedBy(value="AbstractResourceRepository.ITEM_MAP_LOCK") public abstract java.util.Set<com.android.ide.common.rendering.api.ResourceNamespace> getNamespaces()
@NonNull @GuardedBy(value="AbstractResourceRepository.ITEM_MAP_LOCK") protected final com.google.common.collect.ListMultimap<java.lang.String,ResourceItem> getMap(@NonNull com.android.ide.common.rendering.api.ResourceNamespace namespace, @NonNull com.android.resources.ResourceType type)
@NonNull @GuardedBy(value="AbstractResourceRepository.ITEM_MAP_LOCK") public ResourceTable getItems()
@NonNull public final java.util.List<ResourceItem> getAllResourceItems()
@Nullable @Deprecated public java.util.List<ResourceItem> getResourceItem(@NonNull com.android.resources.ResourceType resourceType, @NonNull java.lang.String resourceName)
@NonNull public java.util.List<ResourceItem> getResourceItems(@NonNull com.android.ide.common.rendering.api.ResourceNamespace namespace, @NonNull com.android.resources.ResourceType resourceType, @NonNull java.lang.String resourceName)
@NonNull
public java.util.Collection<java.lang.String> getItemsOfType(@NonNull
com.android.resources.ResourceType type)
@NonNull
public java.util.Collection<java.lang.String> getItemsOfType(com.android.ide.common.rendering.api.ResourceNamespace namespace,
@NonNull
com.android.resources.ResourceType type)
public boolean hasResourceItem(@NonNull
java.lang.String url)
url - the resource URLpublic boolean hasResourceItem(@NonNull
com.android.resources.ResourceType resourceType,
@NonNull
java.lang.String resourceName)
resourceType - the type of resource to look upresourceName - the name of the resourcepublic boolean hasResourcesOfType(@NonNull
com.android.resources.ResourceType resourceType)
ResourceType.resourceType - the type of resource to check.@NonNull public java.util.List<com.android.resources.ResourceType> getAvailableResourceTypes()
@Nullable public ResourceFile getMatchingFile(@NonNull java.lang.String name, @NonNull com.android.resources.ResourceType type, @NonNull FolderConfiguration config)
ResourceFile matching the given name, ResourceType and
configuration.
This only works with files generating one resource named after the file (for instance, layouts, bitmap based drawable, xml, anims).
name - the resource nametype - the folder type search forconfig - the folder configuration to match fornull if no match was found.@NonNull public java.util.List<ResourceFile> getMatchingFiles(@NonNull java.lang.String name, @NonNull com.android.resources.ResourceType type, @NonNull FolderConfiguration config)
ResourceFile matching the given name, ResourceType and
configuration. This ignores the qualifiers which are missing from the configuration.
This only works with files generating one resource named after the file (for instance, layouts, bitmap based drawable, xml, anims).
name - the resource nametype - the folder type search forconfig - the folder configuration to match forgetMatchingFile(String, ResourceType, FolderConfiguration)@NonNull public com.google.common.collect.Table<com.android.ide.common.rendering.api.ResourceNamespace,com.android.resources.ResourceType,ResourceValueMap> getConfiguredResources(@NonNull FolderConfiguration referenceConfig)
FolderConfiguration.referenceConfig - the configuration that each value must match.Table with one row for every namespace present in this repository, where
every row contains an entry for all resource types.@NonNull public ResourceValueMap getConfiguredResources(@NonNull com.android.ide.common.rendering.api.ResourceNamespace namespace, @NonNull com.android.resources.ResourceType type, @NonNull FolderConfiguration referenceConfig)
ResourceType.
The values returned are taken from the resource files best matching a given FolderConfiguration.
namespace - namespaces of the resourcestype - the type of the resources.referenceConfig - the configuration to best match.@Nullable
public com.android.ide.common.rendering.api.ResourceValue getConfiguredValue(@NonNull
com.android.resources.ResourceType type,
@NonNull
java.lang.String name,
@NonNull
FolderConfiguration referenceConfig)
@NonNull public java.util.SortedSet<java.lang.String> getLanguages()
@NonNull public java.util.SortedSet<LocaleQualifier> getLocales()
@NonNull
public java.util.SortedSet<java.lang.String> getRegions(@NonNull
java.lang.String currentLanguage)
currentLanguage - the current language the region must be associated with.