Package com.iizix.urn
Class URNResource
- java.lang.Object
- com.iizix.urn.URN
- com.iizix.urn.URNResource
- Direct Known Subclasses:
FileURN
public abstract class URNResource extends URN
The URN resource contains information of for local server environment from where it was originated. Thus the final URL could vary depending on the server and/or cluster configuration.Resource URN's are encoded in IIZI as:
urn:nssPrefix:type:identifier
where the valid
nssPrefix
currently values are:and
type
s are (in lower case):{@link URNResourceType#COMMON_DATABASE_PERSISTENT}
:
Common server files stored in database (cached on the server even for starts/stops),{@link URNResourceType#COMMON_PERSISTENT}
:
Common server files (persists when server starts/stops),{@link URNResourceType#COMMON_VOLATILE}
:
Common server files (volatile when server starts/stops),{@link URNResourceType#EXTERNAL_FILES}
:
External files (typically accessible using the 'file:' protocol),{@link URNResourceType#APPLICATION_DATABASE_PERSISTENT}
:
Application files in database,{@link URNResourceType#APPLICATION_PERSISTENT}
:
Application files,{@link URNResourceType#APPLICATION_VOLATILE}
:
Application files,{@link URNResourceType#GROUP_DATABASE_FILES}
:
Private user group files stored in database (cached on server),{@link URNResourceType#USER_FILES}
:
Private user files,{@link URNResourceType#USER_DATABASE_FILES}
:
Private user files stored in database (cached on server),{@link URNResourceType#APP_SESSION}
:
Application session (private) files,{@link URNResourceType#CLIENT_SESSION}
:
Client session (private) files.
The
identifier
is file identifier in thetype
identifier.- Author:
- Christopher Mindus
Field Summary
Fields Modifier and Type Field Description protected java.lang.Object
id
The resource ID depending on the type: Long or String.protected URNResourceType
type
The resource type.
Constructor Summary
Constructors Modifier Constructor Description protected
URNResource(java.lang.String urnString, URNResourceType type, java.lang.Object id)
Constructs a URNResource from a string that has contains the media type followed by Base64 encoded data.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description URNResource
asURNResource()
Gets this instance as type.boolean
equals(java.lang.Object obj)
Checks if another URN is equal to this one.java.lang.Object
getID()
Returns the ID used for the resource.IImageTarget
getImageTarget()
Gets the image target interface for this URN instance, if supported.java.lang.String
getParamString()
Gets the parameter string for theURN.toString()
method.URNResourceType
getType()
Gets the resource type.java.lang.String
getURL()
Gets the URL of this resource relative the current web server.int
hashCode()
Gets the hash code of the instance.boolean
isImageTargetSupported()
Checks if this instance supports returning the image target interface{@link IImageTarget}
.boolean
isURNResource()
Checks if this URN instance is a .Methods inherited from class com.iizix.urn.URN
from, getURNString, toString
Field Detail
type
protected final URNResourceType type
The resource type.
id
protected final java.lang.Object id
The resource ID depending on the type: Long or String.
Constructor Detail
URNResource
protected URNResource(java.lang.String urnString, URNResourceType type, java.lang.Object id)
Constructs a URNResource from a string that has contains the media type followed by Base64 encoded data.- Parameters:
urnString
- The URN string formatted the "iizi" way.id
- An ID that is either a {- Throws:
ValueException
- If there is a problem with the URN parsing, e.g. the string doesn't start with "urn:".java.lang.NullPointerException
- If theurnString
,type
orid
isnull
.
Method Detail
getType
public final URNResourceType getType()
Gets the resource type.- Returns:
- The resource type.
getID
public final java.lang.Object getID()
Returns the ID used for the resource.- Returns:
- The ID is of type
Long
for ID's of a User ID, Group or a String for a User ID or Application ID.null
is returned when the URN resource is not related to either a user profile or an application.
getURL
public java.lang.String getURL() throws java.io.IOException
Gets the URL of this resource relative the current web server.
isURNResource
public final boolean isURNResource()
Checks if this URN instance is a .- Overrides:
isURNResource
in classURN
- Returns:
- Always
true
as the instance is always a type.
asURNResource
public final URNResource asURNResource()
Gets this instance as type.- Overrides:
asURNResource
in classURN
- Returns:
- The instance, always
non-null
.
isImageTargetSupported
public boolean isImageTargetSupported()
Checks if this instance supports returning the image target interface{@link IImageTarget}
.- Overrides:
isImageTargetSupported
in classURN
- Returns:
true
if the URN supports the image target interface,false
(default) otherwise.
getImageTarget
public IImageTarget getImageTarget()
Gets the image target interface for this URN instance, if supported.- Overrides:
getImageTarget
in classURN
- Returns:
- The image target interface, or
null
(default) if not supported.
hashCode
public int hashCode()
Gets the hash code of the instance. The original URN string is not used for this hash code, rather the URN 'NID' and the parameters.
equals
public boolean equals(java.lang.Object obj)
Checks if another URN is equal to this one. The original URN string is not used for this comparison, rather the URN 'NID' and the parameters.
getParamString
public java.lang.String getParamString()
Gets the parameter string for theURN.toString()
method.- Specified by:
getParamString
in classURN
- Returns:
- The parameter string, always
non-null
.