Package com.globalmentor.net
Class AbstractResource
- java.lang.Object
-
- com.globalmentor.net.AbstractResource
-
- All Implemented Interfaces:
Resource
- Direct Known Subclasses:
DefaultResource
,ReferenceResource
public abstract class AbstractResource extends java.lang.Object implements Resource
Represents an abstract implementation of a resource.- Author:
- Garret Wilson
-
-
Field Summary
-
Fields inherited from interface com.globalmentor.net.Resource
URI_PROPERTY_NAME
-
-
Constructor Summary
Constructors Constructor Description AbstractResource()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object object)
This implementation compares the resource URIs.int
hashCode()
This implementation returns a hashcode value composed from the reference URI, if available.java.lang.String
toString()
Returns a string representation of the resource.static java.lang.String
toString(Resource resource)
Returns a reference string representation of the given resource.static java.lang.String
toString(java.net.URI resourceURI)
Returns a reference string representation of the resource identified by the given URI.
-
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object object)
This implementation compares the resource URIs. If neither object has a reference URI, the default identity comparison is performed.- Overrides:
equals
in classjava.lang.Object
- See Also:
Resource.getURI()
-
hashCode
public int hashCode()
This implementation returns a hashcode value composed from the reference URI, if available.- Overrides:
hashCode
in classjava.lang.Object
-
toString
public static java.lang.String toString(java.net.URI resourceURI)
Returns a reference string representation of the resource identified by the given URI. This version returns the URI between double angle quotation marks.- Parameters:
resourceURI
- The resource URI for which a reference string should be returned.- Returns:
- A reference string representation of the resource.
- Throws:
java.lang.NullPointerException
- if the given resource URI isnull
.
-
toString
public static java.lang.String toString(Resource resource)
Returns a reference string representation of the given resource. This version returns the URI, if there is one, between double angle quotation marks; otherwise, an ID using the resource's hash code is used.- Parameters:
resource
- The resource for which a reference string should be returned.- Returns:
- A reference string representation of the resource.
- See Also:
toString(URI)
-
toString
public java.lang.String toString()
Returns a string representation of the resource. This version returns the URI, if there is one, between double angle quotation marks; otherwise the default string representation of the object is returned.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of the resource.
- See Also:
toString(Resource)
-
-