public class ResourceItem extends java.lang.Object implements Configurable, java.lang.Comparable<ResourceItem>
This includes the name, type, source file as a ResourceFile and an optional Node in case of a resource coming from a value file.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ATTR_EXAMPLE |
protected com.android.ide.common.rendering.api.ResourceValue |
mResourceValue |
static java.lang.String |
XLIFF_G_TAG |
static java.lang.String |
XLIFF_NAMESPACE_PREFIX |
| Constructor and Description |
|---|
ResourceItem(java.lang.String name,
com.android.ide.common.rendering.api.ResourceNamespace namespace,
com.android.resources.ResourceType type,
org.w3c.dom.Node value,
java.lang.String libraryName)
Constructs the object with a name, type and optional value.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(ResourceItem other) |
boolean |
compareValueWith(ResourceItem resource)
Compares the ResourceItem
getValue() together and returns true if they are the same. |
boolean |
equals(java.lang.Object o) |
FolderConfiguration |
getConfiguration()
Returns the
FolderConfiguration for this object. |
java.io.File |
getFile()
For non-values resources, this is the original source file.
|
boolean |
getIgnoredFromDiskMerge() |
java.lang.String |
getKey()
Returns a key for this resource.
|
java.lang.String |
getLibraryName()
Returns the library that the resource was found.
|
java.lang.String |
getName()
Returns the name of the item.
|
com.android.ide.common.rendering.api.ResourceNamespace |
getNamespace()
Returns the namespace where the resource was defined.
|
java.lang.String |
getQualifiers()
Returns the resource item qualifiers.
|
com.android.ide.common.rendering.api.ResourceReference |
getReferenceToSelf()
Builds a
ResourceReference that points to this ResourceItem. |
com.android.ide.common.rendering.api.ResourceValue |
getResourceValue() |
com.android.ide.common.rendering.api.ResourceValue |
getResourceValue(boolean isFrameworks)
Deprecated.
Use
getResourceValue() instead. |
F |
getSource()
Returns the DataFile the item is coming from.
|
DataFile.FileType |
getSourceType() |
protected int |
getStatus()
Obtains the full status of the data item; should not generally be used except
for debug purposes.
|
com.android.resources.ResourceType |
getType()
Returns the type of the resource.
|
org.w3c.dom.Node |
getValue()
Returns the optional value of the resource.
|
java.lang.String |
getValueText()
Returns the optional string value of the 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. |
int |
hashCode() |
void |
setIgnoredFromDiskMerge(boolean ignored) |
void |
setSource(F sourceFile)
Sets the DataFile.
|
java.lang.String |
toString() |
protected void |
wasTouched()
Hook invoked when the data item has been touched.
|
public static final java.lang.String XLIFF_NAMESPACE_PREFIX
public static final java.lang.String XLIFF_G_TAG
public static final java.lang.String ATTR_EXAMPLE
@Nullable protected com.android.ide.common.rendering.api.ResourceValue mResourceValue
public ResourceItem(@NonNull
java.lang.String name,
@NonNull
com.android.ide.common.rendering.api.ResourceNamespace namespace,
@NonNull
com.android.resources.ResourceType type,
@Nullable
org.w3c.dom.Node value,
@Nullable
java.lang.String libraryName)
Note that the object is not fully usable as-is. It must be added to a ResourceFile first.
name - the name of the resourcenamespace - the namespace of the resourcetype - the type of the resourcevalue - an optional Node that represents the resource value.@NonNull public com.android.resources.ResourceType getType()
@Nullable public org.w3c.dom.Node getValue()
@Nullable public java.lang.String getValueText()
@Nullable public java.lang.String getLibraryName()
@NonNull public com.android.ide.common.rendering.api.ResourceNamespace getNamespace()
@NonNull public java.lang.String getQualifiers()
@NonNull public DataFile.FileType getSourceType()
@NonNull public com.android.ide.common.rendering.api.ResourceReference getReferenceToSelf()
ResourceReference that points to this ResourceItem.public FolderConfiguration getConfiguration()
ConfigurableFolderConfiguration for this object.getConfiguration in interface Configurablepublic java.lang.String getKey()
If the resource has not been added to a ResourceFile, this will throw an IllegalStateException.
java.lang.IllegalStateException - if the resource is not added to a ResourceFileprotected void wasTouched()
@Nullable public com.android.ide.common.rendering.api.ResourceValue getResourceValue()
@Deprecated @Nullable public com.android.ide.common.rendering.api.ResourceValue getResourceValue(boolean isFrameworks)
getResourceValue() instead.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 boolean compareValueWith(ResourceItem resource)
getValue() together and returns true if they are the same.resource - The ResourceItem object to compare to.public java.lang.String toString()
public boolean equals(java.lang.Object o)
public int hashCode()
public int compareTo(@NonNull
ResourceItem other)
compareTo in interface java.lang.Comparable<ResourceItem>public void setIgnoredFromDiskMerge(boolean ignored)
public boolean getIgnoredFromDiskMerge()
@NonNull public java.lang.String getName()
@Nullable public F getSource()
public void setSource(@Nullable
F sourceFile)
sourceFile - the data file, if null then the item is marked as being removed from the
data fileprotected int getStatus()
@Nullable public java.io.File getFile()
GeneratedResourceItem overrides it.