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.
|
static int |
MAX_RESOURCE_INDIRECTION
Number of indirections we'll follow for resource resolution before assuming there is a cyclic
dependency error in the input.
|
| Constructor and Description |
|---|
AbstractResourceRepository() |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<ResourceItem> |
getAllResourceItems() |
com.google.common.collect.ImmutableSet<com.android.resources.ResourceType> |
getAvailableResourceTypes(com.android.ide.common.rendering.api.ResourceNamespace namespace) |
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)
Deprecated.
Use
getItemsOfType(ResourceNamespace, ResourceType) instead. |
void |
getLeafResourceRepositories(java.util.Collection<AbstractResourceRepository> result)
Returns all leaf resource repositories contained in this resource repository including this
repository itself, if it does not contain any other repositories.
|
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) |
abstract java.util.Set<com.android.ide.common.rendering.api.ResourceNamespace> |
getNamespaces() |
java.util.Collection<ResourceItem> |
getPublicResourcesOfType(com.android.resources.ResourceType type)
Returns a collection of public resource items matching a given resource type.
|
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)
Returns the resources with the given namespace and type.
|
java.util.List<ResourceItem> |
getResourceItems(com.android.ide.common.rendering.api.ResourceNamespace namespace,
com.android.resources.ResourceType resourceType,
java.util.function.Predicate<ResourceItem> filter)
Returns the resources with the given namespace, type and with a name satisfying the given
predicate.
|
java.util.List<ResourceItem> |
getResourceItems(com.android.ide.common.rendering.api.ResourceNamespace namespace,
com.android.resources.ResourceType resourceType,
java.lang.String resourceName) |
java.util.List<ResourceItem> |
getResourceItems(com.android.ide.common.rendering.api.ResourceReference reference) |
boolean |
hasResourceItem(com.android.ide.common.rendering.api.ResourceNamespace namespace,
com.android.resources.ResourceType resourceType,
java.lang.String resourceName)
Returns true if this resource repository contains a resource of the given name.
|
boolean |
hasResourceItem(com.android.resources.ResourceType resourceType,
java.lang.String resourceName)
|
boolean |
hasResourceItem(java.lang.String url)
Returns true if this resource repository contains a resource of the given name.
|
boolean |
hasResourcesOfType(com.android.ide.common.rendering.api.ResourceNamespace namespace,
com.android.resources.ResourceType resourceType)
Returns whether the repository has resources of a given
ResourceType. |
boolean |
hasResourcesOfType(com.android.resources.ResourceType resourceType)
Returns whether the repository has resources of a given
ResourceType. |
public static final int MAX_RESOURCE_INDIRECTION
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).
public void getLeafResourceRepositories(@NonNull
java.util.Collection<AbstractResourceRepository> result)
result - the collection to add the leaf repositories to@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()
@Deprecated @Nullable public java.util.List<ResourceItem> getResourceItem(@NonNull com.android.resources.ResourceType resourceType, @NonNull java.lang.String resourceName)
getResourceItems(ResourceNamespace, ResourceType, String) instead.@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.List<ResourceItem> getResourceItems(@NonNull com.android.ide.common.rendering.api.ResourceNamespace namespace, @NonNull com.android.resources.ResourceType resourceType, @NonNull java.util.function.Predicate<ResourceItem> filter)
namespace - the namespace of the resources to returnresourceType - the type of the resources to returnfilter - the predicate for checking resource items@NonNull public java.util.List<ResourceItem> getResourceItems(@NonNull com.android.ide.common.rendering.api.ResourceNamespace namespace, @NonNull com.android.resources.ResourceType resourceType)
namespace - the namespace of the resources to returnresourceType - the type of the resources to return@NonNull public java.util.List<ResourceItem> getResourceItems(@NonNull com.android.ide.common.rendering.api.ResourceReference reference)
@Deprecated
@NonNull
public final java.util.Collection<java.lang.String> getItemsOfType(@NonNull
com.android.resources.ResourceType type)
getItemsOfType(ResourceNamespace, ResourceType) instead.@NonNull
public java.util.Collection<java.lang.String> getItemsOfType(@NonNull
com.android.ide.common.rendering.api.ResourceNamespace namespace,
@NonNull
com.android.resources.ResourceType type)
@NonNull public java.util.Collection<ResourceItem> getPublicResourcesOfType(@NonNull com.android.resources.ResourceType type)
This implementation returns an empty collection. Subclasses may override this behavior.
type - the type of the resources to returnpublic boolean hasResourceItem(@NonNull
java.lang.String url)
url - the resource URL@Deprecated
public boolean hasResourceItem(@NonNull
com.android.resources.ResourceType resourceType,
@NonNull
java.lang.String resourceName)
public boolean hasResourceItem(@NonNull
com.android.ide.common.rendering.api.ResourceNamespace namespace,
@NonNull
com.android.resources.ResourceType resourceType,
@NonNull
java.lang.String resourceName)
namespace - the namespace of the resource to look upresourceType - 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.public boolean hasResourcesOfType(@NonNull
com.android.ide.common.rendering.api.ResourceNamespace namespace,
@NonNull
com.android.resources.ResourceType resourceType)
ResourceType.
Do not call this method if you you are going to call
getItemsOfType(ResourceNamespace, ResourceType) or
getResourceItems(ResourceNamespace, ResourceType) immediately after.
resourceType - the type of resource to check.@NonNull
public com.google.common.collect.ImmutableSet<com.android.resources.ResourceType> getAvailableResourceTypes(@NonNull
com.android.ide.common.rendering.api.ResourceNamespace namespace)
@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<LocaleQualifier> getLocales()