com.android.ide.common.res2
Class ResourceItem

java.lang.Object
  extended by com.android.ide.common.res2.ResourceItem
All Implemented Interfaces:
Configurable, java.lang.Comparable<ResourceItem>

public class ResourceItem
extends java.lang.Object
implements Configurable, java.lang.Comparable<ResourceItem>

A resource. This includes the name, type, source file as a ResourceFile and an optional Node in case of a resource coming from a value file.


Field Summary
protected  com.android.ide.common.rendering.api.ResourceValue mResourceValue
           
 
Constructor Summary
ResourceItem(java.lang.String name, com.android.resources.ResourceType type, org.w3c.dom.Node value)
          Constructs the object with a name, type and optional value.
 
Method Summary
 int compareTo(ResourceItem resourceItem)
           
 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.
 boolean getIgnoredFromDiskMerge()
           
 java.lang.String getKey()
          Returns a key for this resource.
 java.lang.String getName()
          Returns the name of the item.
 com.android.ide.common.rendering.api.ResourceValue getResourceValue(boolean isFrameworks)
           
 F getSource()
          Returns the DataFile the item is coming from.
protected  int getStatus()
           
 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()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

mResourceValue

protected com.android.ide.common.rendering.api.ResourceValue mResourceValue
Constructor Detail

ResourceItem

public ResourceItem(@NonNull
                    java.lang.String name,
                    @NonNull
                    com.android.resources.ResourceType type,
                    org.w3c.dom.Node value)
Constructs the object with a name, type and optional value. Note that the object is not fully usable as-is. It must be added to a ResourceFile first.

Parameters:
name - the name of the resource
type - the type of the resource
value - an optional Node that represents the resource value.
Method Detail

getType

@NonNull
public com.android.resources.ResourceType getType()
Returns the type of the resource.

Returns:
the type.

getValue

@Nullable
public org.w3c.dom.Node getValue()
Returns the optional value of the resource. Can be null

Returns:
the value or null.

getValueText

@Nullable
public java.lang.String getValueText()
Returns the optional string value of the resource. Can be null

Returns:
the value or null.

getConfiguration

public FolderConfiguration getConfiguration()
Description copied from interface: Configurable
Returns the FolderConfiguration for this object.

Specified by:
getConfiguration in interface Configurable

getKey

public java.lang.String getKey()
Returns a key for this resource. They key uniquely identifies this resource by combining resource type, qualifiers, and name. If the resource has not been added to a ResourceFile, this will throw an IllegalStateException.

Returns:
the key for this resource.
Throws:
java.lang.IllegalStateException - if the resource is not added to a ResourceFile

wasTouched

protected void wasTouched()

getResourceValue

@Nullable
public com.android.ide.common.rendering.api.ResourceValue getResourceValue(boolean isFrameworks)

getXmlString

public java.lang.String getXmlString(com.android.resources.ResourceType type,
                                     boolean system)
Returns a formatted string usable in an XML to use for the ResourceItem.

Parameters:
system - Whether this is a system resource or a project resource.
Returns:
a string in the format @[type]/[name]

compareValueWith

public boolean compareValueWith(ResourceItem resource)
Compares the ResourceItem getValue() together and returns true if they are the same.

Parameters:
resource - The ResourceItem object to compare to.
Returns:
true if equal

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)

hashCode

public int hashCode()

compareTo

public int compareTo(@NonNull
                     ResourceItem resourceItem)
Specified by:
compareTo in interface java.lang.Comparable<ResourceItem>

setIgnoredFromDiskMerge

public void setIgnoredFromDiskMerge(boolean ignored)

getIgnoredFromDiskMerge

public boolean getIgnoredFromDiskMerge()

getName

@NonNull
public java.lang.String getName()
Returns the name of the item.

Returns:
the name.

getSource

@Nullable
public F getSource()
Returns the DataFile the item is coming from. Can be null.

Returns:
the data file.

setSource

public void setSource(F sourceFile)
Sets the DataFile

Parameters:
sourceFile - the DataFile

getStatus

protected int getStatus()