|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.android.ide.common.resources.ResourceRepository
public abstract class ResourceRepository
Base class for resource repository.
A repository is both a file representation of a resource folder and a representation
of the generated resources, organized by type.
getResourceFolder(IAbstractFolder) and getSourceFiles(ResourceType, String, FolderConfiguration)
give access to the folders and files of the resource folder.
getResourceItemsOfType(ResourceType) gives access to the resources directly.
| Field Summary | |
|---|---|
protected java.util.Map<com.android.resources.ResourceFolderType,java.util.List<ResourceFolder>> |
mFolderMap
|
protected java.util.Map<com.android.resources.ResourceType,java.util.Map<java.lang.String,ResourceItem>> |
mResourceMap
|
| Constructor Summary | |
|---|---|
protected |
ResourceRepository(com.android.io.IAbstractFolder resFolder,
boolean isFrameworkRepository)
Makes a resource repository |
| Method Summary | |
|---|---|
void |
clear()
|
protected abstract ResourceItem |
createResourceItem(java.lang.String name)
Creates a resource item with the given name. |
protected java.util.Map<com.android.resources.ResourceType,java.util.Map<java.lang.String,com.android.ide.common.rendering.api.ResourceValue>> |
doGetConfiguredResources(FolderConfiguration referenceConfig)
Returns the resources values matching a given FolderConfiguration for the current
project. |
boolean |
ensureInitialized()
Ensures that the repository has been initialized again after a call to clear() |
protected ResourceFile |
findResourceFile(java.io.File file)
Looks up the ResourceFile for the given File, if possible |
java.util.List<com.android.resources.ResourceType> |
getAvailableResourceTypes()
|
java.util.Map<com.android.resources.ResourceType,java.util.Map<java.lang.String,com.android.ide.common.rendering.api.ResourceValue>> |
getConfiguredResources(FolderConfiguration referenceConfig)
Returns the resources values matching a given FolderConfiguration. |
java.util.List<ResourceFolder> |
getFolders(com.android.resources.ResourceFolderType type)
Returns a list of ResourceFolder for a specific ResourceFolderType. |
java.util.SortedSet<java.lang.String> |
getLanguages()
Returns the sorted list of languages used in the resources. |
ResourceFile |
getMatchingFile(java.lang.String name,
com.android.resources.ResourceFolderType type,
FolderConfiguration config)
Returns the ResourceFile matching the given name,
ResourceFolderType and configuration. |
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.SortedSet<java.lang.String> |
getRegions(java.lang.String currentLanguage)
Returns the sorted list of regions used in the resources with the given language. |
com.android.io.IAbstractFolder |
getResFolder()
|
ResourceFolder |
getResourceFolder(com.android.io.IAbstractFolder folder)
Returns the ResourceFolder associated with a IAbstractFolder. |
ResourceItem |
getResourceItem(com.android.resources.ResourceType type,
java.lang.String name)
Returns a ResourceItem matching the given ResourceType and name. |
java.util.Collection<ResourceItem> |
getResourceItemsOfType(com.android.resources.ResourceType type)
Returns a list of ResourceItem matching a given ResourceType. |
java.util.List<ResourceFile> |
getSourceFiles(com.android.resources.ResourceType type,
java.lang.String name,
FolderConfiguration referenceConfig)
Returns the list of source files for a given resource. |
boolean |
hasResourceItem(com.android.resources.ResourceType type,
java.lang.String name)
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 type)
Returns whether the repository has resources of a given ResourceType. |
boolean |
isFrameworkRepository()
|
void |
loadResources()
Loads the resources. |
void |
postUpdateCleanUp()
Cleans up the repository of resource items that have no source file anymore. |
ResourceFolder |
processFolder(com.android.io.IAbstractFolder folder)
Processes a folder and adds it to the list of existing folders. |
protected void |
removeFile(java.util.Collection<com.android.resources.ResourceType> types,
ResourceFile file)
|
protected void |
removeFile(com.android.resources.ResourceType type,
ResourceFile file)
|
ResourceFolder |
removeFolder(com.android.resources.ResourceFolderType type,
com.android.io.IAbstractFolder removedFolder,
ScanningContext context)
Removes a ResourceFolder associated with the specified IAbstractFolder. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.util.Map<com.android.resources.ResourceFolderType,java.util.List<ResourceFolder>> mFolderMap
protected java.util.Map<com.android.resources.ResourceType,java.util.Map<java.lang.String,ResourceItem>> mResourceMap
| Constructor Detail |
|---|
protected ResourceRepository(@NonNull
com.android.io.IAbstractFolder resFolder,
boolean isFrameworkRepository)
resFolder - the resource folder of the repository.isFrameworkRepository - whether the repository is for framework resources.| Method Detail |
|---|
public com.android.io.IAbstractFolder getResFolder()
public boolean isFrameworkRepository()
public void clear()
public boolean ensureInitialized()
clear()
@Nullable
public ResourceFolder removeFolder(@NonNull
com.android.resources.ResourceFolderType type,
@NonNull
com.android.io.IAbstractFolder removedFolder,
@Nullable
ScanningContext context)
ResourceFolder associated with the specified IAbstractFolder.
type - The type of the folderremovedFolder - the IAbstractFolder object.context - the scanning context
ResourceFolder that was removed, or null if no matches were found.
public boolean hasResourceItem(@NonNull
java.lang.String url)
url - the resource URL
public boolean hasResourceItem(@NonNull
com.android.resources.ResourceType type,
@NonNull
java.lang.String name)
type - the type of resource to look upname - the name of the resource
@NonNull
public ResourceItem getResourceItem(@NonNull
com.android.resources.ResourceType type,
@NonNull
java.lang.String name)
ResourceItem matching the given ResourceType and name. If none
exist, it creates one.
type - the resource typename - the name of the resource.
@NonNull
protected abstract ResourceItem createResourceItem(@NonNull
java.lang.String name)
name - the name of the resource
@Nullable
public ResourceFolder processFolder(@NonNull
com.android.io.IAbstractFolder folder)
folder - the folder to process
@Nullable
public java.util.List<ResourceFolder> getFolders(@NonNull
com.android.resources.ResourceFolderType type)
ResourceFolder for a specific ResourceFolderType.
type - The ResourceFolderType@NonNull public java.util.List<com.android.resources.ResourceType> getAvailableResourceTypes()
@NonNull
public java.util.Collection<ResourceItem> getResourceItemsOfType(@NonNull
com.android.resources.ResourceType type)
ResourceItem matching a given ResourceType.
type - the type of the resource items to return
public boolean hasResourcesOfType(@NonNull
com.android.resources.ResourceType type)
ResourceType.
type - the type of resource to check.
@Nullable
public ResourceFolder getResourceFolder(@NonNull
com.android.io.IAbstractFolder folder)
ResourceFolder associated with a IAbstractFolder.
folder - The IAbstractFolder object.
ResourceFolder or null if it was not found.
@Nullable
public ResourceFile getMatchingFile(@NonNull
java.lang.String name,
@NonNull
com.android.resources.ResourceFolderType type,
@NonNull
FolderConfiguration config)
ResourceFile matching the given name,
ResourceFolderType 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 name or file nametype - the folder type search forconfig - the folder configuration to match for
null if no match was found.
@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 name or file nametype - the folder type search forconfig - the folder configuration to match for
null if no match was found.
@Nullable
protected ResourceFile findResourceFile(@NonNull
java.io.File file)
ResourceFile for the given File, if possible
file - the file
ResourceFile, or null if not a known ResourceFile
@Nullable
public java.util.List<ResourceFile> getSourceFiles(@NonNull
com.android.resources.ResourceType type,
@NonNull
java.lang.String name,
@Nullable
FolderConfiguration referenceConfig)
FolderConfiguration is given, then only the best
match for this config is returned.
type - the type of the resource.name - the name of the resource.referenceConfig - an optional config for which only the best match will be returned.
@NonNull
public java.util.Map<com.android.resources.ResourceType,java.util.Map<java.lang.String,com.android.ide.common.rendering.api.ResourceValue>> getConfiguredResources(@NonNull
FolderConfiguration referenceConfig)
FolderConfiguration.
referenceConfig - the configuration that each value must match.
ResourceType
@NonNull
protected final java.util.Map<com.android.resources.ResourceType,java.util.Map<java.lang.String,com.android.ide.common.rendering.api.ResourceValue>> doGetConfiguredResources(@NonNull
FolderConfiguration referenceConfig)
FolderConfiguration for the current
project.
referenceConfig - the configuration that each value must match.
ResourceType@NonNull public java.util.SortedSet<java.lang.String> getLanguages()
@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 loadResources()
protected void removeFile(@NonNull
java.util.Collection<com.android.resources.ResourceType> types,
@NonNull
ResourceFile file)
protected void removeFile(@NonNull
com.android.resources.ResourceType type,
@NonNull
ResourceFile file)
public void postUpdateCleanUp()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||