public abstract class AbstractResourceRepository extends java.lang.Object implements ResourceRepository
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 |
|---|---|
void |
accept(ResourceVisitor visitor)
Calls the
ResourceVisitor.visit(ResourceItem) method for all resources in
the repository. |
protected abstract ResourceTable |
getFullTable()
Returns the fully computed
ResourceTable for this repository. |
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) |
java.util.Collection<ResourceItem> |
getPublicResources(com.android.ide.common.rendering.api.ResourceNamespace namespace,
com.android.resources.ResourceType type)
Returns a collection of public resource items with the given namespace and type.
|
com.google.common.collect.ListMultimap<java.lang.String,ResourceItem> |
getResources(com.android.ide.common.rendering.api.ResourceNamespace namespace,
com.android.resources.ResourceType resourceType)
Returns the resources with the given namespace and type keyed by resource names.
|
java.util.List<ResourceItem> |
getResources(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 satisfying the given predicate.
|
java.util.List<ResourceItem> |
getResources(com.android.ide.common.rendering.api.ResourceNamespace namespace,
com.android.resources.ResourceType resourceType,
java.lang.String resourceName)
Returns the resources with the given namespace, type and name.
|
java.util.Set<com.android.resources.ResourceType> |
getResourceTypes(com.android.ide.common.rendering.api.ResourceNamespace namespace)
Returns types of the resources in the given namespace.
|
boolean |
hasResources(com.android.ide.common.rendering.api.ResourceNamespace namespace,
com.android.resources.ResourceType resourceType)
Checks if the repository contains resources with the given namespace and type.
|
boolean |
hasResources(com.android.ide.common.rendering.api.ResourceNamespace namespace,
com.android.resources.ResourceType resourceType,
java.lang.String resourceName)
Checks if the repository contains resources with the given namespace, type and name.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAllResources, getLeafResourceRepositories, getNamespaces, getResourcespublic 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).
@GuardedBy(value="AbstractResourceRepository.ITEM_MAP_LOCK") @NonNull protected abstract ResourceTable getFullTable()
ResourceTable for this repository.
The returned object should be accessed only while holding ITEM_MAP_LOCK.
@GuardedBy(value="AbstractResourceRepository.ITEM_MAP_LOCK") @Nullable 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)
@GuardedBy(value="AbstractResourceRepository.ITEM_MAP_LOCK") @NonNull 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 public java.util.List<ResourceItem> getResources(@NonNull com.android.ide.common.rendering.api.ResourceNamespace namespace, @NonNull com.android.resources.ResourceType resourceType, @NonNull java.lang.String resourceName)
ResourceRepositorygetResources in interface ResourceRepositorynamespace - the namespace of the resources to returnresourceType - the type of the resources to returnresourceName - the bane of the resources to return@NonNull public java.util.List<ResourceItem> getResources(@NonNull com.android.ide.common.rendering.api.ResourceNamespace namespace, @NonNull com.android.resources.ResourceType resourceType, @NonNull java.util.function.Predicate<ResourceItem> filter)
ResourceRepositorygetResources in interface ResourceRepositorynamespace - the namespace of the resources to returnresourceType - the type of the resources to returnfilter - the predicate for checking resource items@NonNull public com.google.common.collect.ListMultimap<java.lang.String,ResourceItem> getResources(@NonNull com.android.ide.common.rendering.api.ResourceNamespace namespace, @NonNull com.android.resources.ResourceType resourceType)
ResourceRepositorygetResources in interface ResourceRepositorynamespace - the namespace of the resources to returnresourceType - the type of the resources to returnpublic void accept(@NonNull
ResourceVisitor visitor)
ResourceRepositoryResourceVisitor.visit(ResourceItem) method for all resources in
the repository. The visitor should not perform any long running operations or operations
involving locks.accept in interface ResourceRepositoryvisitor - the visitor object@NonNull public java.util.Collection<ResourceItem> getPublicResources(@NonNull com.android.ide.common.rendering.api.ResourceNamespace namespace, @NonNull com.android.resources.ResourceType type)
ResourceRepositorygetPublicResources in interface ResourceRepositorynamespace - the namespace of the resources to returntype - the type of the resources to returnpublic boolean hasResources(@NonNull
com.android.ide.common.rendering.api.ResourceNamespace namespace,
@NonNull
com.android.resources.ResourceType resourceType,
@NonNull
java.lang.String resourceName)
ResourceRepositoryhasResources in interface ResourceRepositorynamespace - the namespace of the resources to checkresourceType - the type of the resources to checkresourceName - the name of the resources to checkpublic boolean hasResources(@NonNull
com.android.ide.common.rendering.api.ResourceNamespace namespace,
@NonNull
com.android.resources.ResourceType resourceType)
ResourceRepositoryhasResources in interface ResourceRepositorynamespace - the namespace of the resources to checkresourceType - the type of the resources to check@NonNull
public java.util.Set<com.android.resources.ResourceType> getResourceTypes(@NonNull
com.android.ide.common.rendering.api.ResourceNamespace namespace)
ResourceRepositorygetResourceTypes in interface ResourceRepositorynamespace - the namespace to get resource types for