public class ResourceMergerItem extends java.lang.Object implements java.lang.Comparable<ResourceMergerItem>, 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 |
BY_KEY| Constructor and Description |
|---|
ResourceMergerItem(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(ResourceMergerItem other) |
boolean |
compareValueWith(ResourceMergerItem 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()
Returns the
File from which this DataItem was created, if known. |
boolean |
getIgnoredFromDiskMerge() |
java.lang.String |
getKey()
Returns a key for this resource.
|
java.lang.String |
getLibraryName()
Returns name of the library which defines this resource, or null for app resources.
|
java.lang.String |
getName()
Returns the name of the item.
|
com.android.ide.common.rendering.api.ResourceNamespace |
getNamespace()
Returns the of this resource.
|
java.lang.String |
getQualifiers()
Returns the resource item qualifiers.
|
com.android.ide.common.rendering.api.ResourceReference |
getReferenceToSelf()
Returns a
ResourceReference that points to this resource. |
com.android.ide.common.rendering.api.ResourceValue |
getResourceValue()
Returns a
ResourceValue built from parsing the XML for this resource. |
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 this 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
ResourceMergerItem. |
int |
hashCode() |
boolean |
isFileBased()
Returns true if the
ResourceItem represents a whole file, not an XML tag within a
values XML file. |
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.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetFile, getNamepublic 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 ResourceMergerItem(@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()
ResourceItemgetType in interface ResourceItem@Nullable public org.w3c.dom.Node getValue()
@Nullable public java.lang.String getValueText()
@Nullable public java.lang.String getLibraryName()
ResourceItemThe contents of the string depend on the build system used to create the ResourceItems.
getLibraryName in interface ResourceItem@NonNull public com.android.ide.common.rendering.api.ResourceNamespace getNamespace()
ResourceItemgetNamespace in interface ResourceItem@NonNull public java.lang.String getQualifiers()
@NonNull public DataFile.FileType getSourceType()
@NonNull public com.android.ide.common.rendering.api.ResourceReference getReferenceToSelf()
ResourceItemResourceReference that points to this resource.getReferenceToSelf in interface ResourceItem@NotNull public FolderConfiguration getConfiguration()
ConfigurableFolderConfiguration for this object.getConfiguration in interface Configurable@NotNull public java.lang.String getKey()
If the resource has not been added to a ResourceFile, this will throw an IllegalStateException.
getKey in interface ResourceItemjava.lang.IllegalStateException - if the resource is not added to a ResourceFileprotected void wasTouched()
@NonNull public com.android.ide.common.rendering.api.ResourceValue getResourceValue()
ResourceItemResourceValue built from parsing the XML for this resource. This can be
used to inspect the value of the resource.
The concrete type of the returned object depends on ResourceItem.getType().
getResourceValue in interface ResourceItemResourceValue or null if there was an error parsing the XML or the
XML is no longer accessible (this may be the case in the IDE, when the item is based on
old PSI).public boolean isFileBased()
ResourceItemResourceItem represents a whole file, not an XML tag within a
values XML file. This is the case for e.g. layouts or colors defined as state lists.isFileBased in interface ResourceItempublic java.lang.String getXmlString(com.android.resources.ResourceType type,
boolean system)
ResourceMergerItem.system - Whether this is a system resource or a project resource.public boolean compareValueWith(ResourceMergerItem 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
ResourceMergerItem other)
compareTo in interface java.lang.Comparable<ResourceMergerItem>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()
File from which this DataItem was created, if known. For some
subclasses of DataItem, the file is known even if getSource() returns null.