@Immutable
public final class ResourceReference
extends java.lang.Object
implements java.io.Serializable
This is an immutable class.
| Constructor and Description |
|---|
ResourceReference(ResourceNamespace namespace,
ResourceType resourceType,
java.lang.String name)
Initializes a ResourceReference.
|
| Modifier and Type | Method and Description |
|---|---|
static ResourceReference |
attr(ResourceNamespace namespace,
java.lang.String name)
A shorthand for creating a
ResourceType.ATTR resource reference. |
boolean |
equals(java.lang.Object o) |
java.lang.String |
getName()
Returns the name of the resource, as defined in the XML.
|
ResourceNamespace |
getNamespace() |
java.lang.String |
getQualifiedName()
If the package name of the namespace is not null, returns the name of the resource prefixed
by the package name with a colon separator.
|
ResourceUrl |
getRelativeResourceUrl(ResourceNamespace context)
Returns a
ResourceUrl that can be used to refer to this resource from the given
namespace. |
ResourceUrl |
getRelativeResourceUrl(ResourceNamespace context,
ResourceNamespace.Resolver resolver)
Returns a
ResourceUrl that can be used to refer to this resource from the given
namespace. |
ResourceType |
getResourceType() |
ResourceUrl |
getResourceUrl() |
int |
hashCode() |
boolean |
isFramework()
Deprecated.
all namespaces should be handled not just "android:".
|
static ResourceReference |
style(ResourceNamespace namespace,
java.lang.String name)
A shorthand for creating a
ResourceType.STYLE resource reference. |
static ResourceReference |
styleable(ResourceNamespace namespace,
java.lang.String name)
A shorthand for creating a
ResourceType.STYLEABLE resource reference. |
java.lang.String |
toString() |
public ResourceReference(@NonNull
ResourceNamespace namespace,
@NonNull
ResourceType resourceType,
@NonNull
java.lang.String name)
namespace - the namespace of the resourceresourceType - the type of the resourcename - the name of the resource, should not be qualifiedpublic static ResourceReference attr(@NonNull ResourceNamespace namespace, @NonNull java.lang.String name)
ResourceType.ATTR resource reference.public static ResourceReference style(@NonNull ResourceNamespace namespace, @NonNull java.lang.String name)
ResourceType.STYLE resource reference.public static ResourceReference styleable(@NonNull ResourceNamespace namespace, @NonNull java.lang.String name)
ResourceType.STYLEABLE resource reference.@NonNull public java.lang.String getName()
public java.lang.String getQualifiedName()
@NonNull public ResourceType getResourceType()
@NonNull public ResourceNamespace getNamespace()
@Deprecated public final boolean isFramework()
true) or a project resource
(false).@NonNull public ResourceUrl getResourceUrl()
@NonNull public ResourceUrl getRelativeResourceUrl(@NonNull ResourceNamespace context)
ResourceUrl that can be used to refer to this resource from the given
namespace. This means the namespace part of the ResourceUrl will be null if the
context namespace is the same as the namespace of this resource.
This method assumes no namespace prefixes (aliases) are defined, so the returned ResourceUrl will use the full package name of the target namespace, if necessary. Most use
cases should attempt to call the overloaded method instead and provide a ResourceNamespace.Resolver from the XML element where the ResourceUrl will be used.
@NonNull public ResourceUrl getRelativeResourceUrl(@NonNull ResourceNamespace context, @NonNull ResourceNamespace.Resolver resolver)
ResourceUrl that can be used to refer to this resource from the given
namespace. This means the namespace part of the ResourceUrl will be null if the
context namespace is the same as the namespace of this resource.
This method uses the provided ResourceNamespace.Resolver to find the short prefix
that can be used to refer to the target namespace. If it is not found, the full package name
is used.
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object