public abstract class AbstractResourceRepository
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static java.lang.Object |
ITEM_MAP_LOCK
Lock used to protect map access
|
Constructor and Description |
---|
AbstractResourceRepository(boolean isFramework) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
MergeConsumer<ResourceItem> |
createMergeConsumer() |
java.util.List<com.android.resources.ResourceType> |
getAvailableResourceTypes() |
java.util.Map<com.android.resources.ResourceType,ResourceValueMap> |
getConfiguredResources(FolderConfiguration referenceConfig)
Returns the resources values matching a given
FolderConfiguration . |
ResourceValueMap |
getConfiguredResources(java.util.Map<com.android.resources.ResourceType,com.google.common.collect.ListMultimap<java.lang.String,ResourceItem>> itemMap,
com.android.resources.ResourceType type,
FolderConfiguration referenceConfig) |
ResourceValueMap |
getConfiguredResources(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) |
java.util.Map<com.android.resources.ResourceType,com.google.common.collect.ListMultimap<java.lang.String,ResourceItem>> |
getItems() |
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 abstract java.util.Map<com.android.resources.ResourceType,com.google.common.collect.ListMultimap<java.lang.String,ResourceItem>> |
getMap() |
protected com.google.common.collect.ListMultimap<java.lang.String,ResourceItem> |
getMap(com.android.resources.ResourceType type) |
protected abstract com.google.common.collect.ListMultimap<java.lang.String,ResourceItem> |
getMap(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. |
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) |
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() |
protected static final java.lang.Object ITEM_MAP_LOCK
public AbstractResourceRepository(boolean isFramework)
public boolean isFramework()
@NonNull public MergeConsumer<ResourceItem> createMergeConsumer()
@NonNull protected abstract java.util.Map<com.android.resources.ResourceType,com.google.common.collect.ListMultimap<java.lang.String,ResourceItem>> getMap()
@Nullable protected abstract com.google.common.collect.ListMultimap<java.lang.String,ResourceItem> getMap(com.android.resources.ResourceType type, boolean create)
@NonNull protected com.google.common.collect.ListMultimap<java.lang.String,ResourceItem> getMap(com.android.resources.ResourceType type)
@NonNull public java.util.Map<com.android.resources.ResourceType,com.google.common.collect.ListMultimap<java.lang.String,ResourceItem>> getItems()
@Nullable public java.util.List<ResourceItem> getResourceItem(@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)
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 java.util.Map<com.android.resources.ResourceType,ResourceValueMap> getConfiguredResources(@NonNull FolderConfiguration referenceConfig)
FolderConfiguration
.referenceConfig
- the configuration that each value must match.ResourceType
@NonNull public ResourceValueMap getConfiguredResources(@NonNull com.android.resources.ResourceType type, @NonNull FolderConfiguration referenceConfig)
ResourceType
.
The values returned are taken from the resource files best matching a given
FolderConfiguration
.
type
- the type of the resources.referenceConfig
- the configuration to best match.@NonNull public ResourceValueMap getConfiguredResources(@NonNull java.util.Map<com.android.resources.ResourceType,com.google.common.collect.ListMultimap<java.lang.String,ResourceItem>> itemMap, @NonNull com.android.resources.ResourceType type, @NonNull FolderConfiguration referenceConfig)
@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.public void clear()