public class ResourceItem extends java.lang.Object implements java.lang.Comparable<ResourceItem>
Constructor and Description |
---|
ResourceItem(java.lang.String name)
Constructs a new ResourceItem.
|
Modifier and Type | Method and Description |
---|---|
protected void |
add(ResourceFile file)
Adds a new source file.
|
int |
compareTo(ResourceItem other)
Compares the
ResourceItem to another. |
int |
getAlternateCount()
Returns the number of alternate versions for this resource.
|
java.lang.String |
getName()
Returns the name of the resource.
|
com.android.ide.common.rendering.api.ResourceValue |
getResourceValue(com.android.resources.ResourceType type,
FolderConfiguration referenceConfig,
boolean isFramework)
Returns a
ResourceValue for this item based on the given configuration. |
ResourceFile[] |
getSourceFileArray()
Returns the sorted list of
ResourceItem objects for this resource item. |
java.util.List<ResourceFile> |
getSourceFileList()
Returns the list of source file for this resource.
|
java.lang.String |
getXmlString(com.android.resources.ResourceType type,
boolean system)
Returns a formatted string usable in an XML to use for the
ResourceItem . |
boolean |
hasAlternates()
Returns if the resource has at least one non-default version.
|
boolean |
hasDefault()
Returns whether the resource has a default version, with no qualifier.
|
protected boolean |
hasNoSourceFile()
Returns
true if the item has no source file. |
boolean |
isDeclaredInline()
Returns whether the ID resource has been declared inline inside another resource XML file.
|
boolean |
isEditableDirectly()
Returns whether the resource is editable directly.
|
protected void |
removeFile(ResourceFile file)
Removes a file from the list of source files.
|
protected void |
reset()
Reset the item by emptying its source file list.
|
java.lang.String |
toString() |
public ResourceItem(java.lang.String name)
name
- the name of the resource as it appears in the XML and R.java files.public final java.lang.String getName()
public int compareTo(ResourceItem other)
ResourceItem
to another.compareTo
in interface java.lang.Comparable<ResourceItem>
other
- the ResourceItem to be compared to.public boolean isEditableDirectly()
This is typically the case for resources that don't have alternate versions, or resources
of type ResourceType.ID
that aren't declared inline.
public boolean isDeclaredInline()
ResourceType.ID
, this will always return false
.public com.android.ide.common.rendering.api.ResourceValue getResourceValue(com.android.resources.ResourceType type, FolderConfiguration referenceConfig, boolean isFramework)
ResourceValue
for this item based on the given configuration.
If the ResourceItem has several source files, one will be selected based on the config.type
- the type of the resource. This is necessary because ResourceItem doesn't embed
its type, but ResourceValue does.referenceConfig
- the config of the resource item.isFramework
- whether the resource is a framework value. Same as the type.protected void add(ResourceFile file)
file
- the source file.protected void removeFile(ResourceFile file)
file
- the file to removeprotected boolean hasNoSourceFile()
true
if the item has no source file.protected void reset()
public ResourceFile[] getSourceFileArray()
ResourceItem
objects for this resource item.public java.util.List<ResourceFile> getSourceFileList()
public boolean hasAlternates()
public boolean hasDefault()
public int getAlternateCount()
public java.lang.String getXmlString(com.android.resources.ResourceType type, boolean system)
ResourceItem
.system
- Whether this is a system resource or a project resource.public java.lang.String toString()
toString
in class java.lang.Object