org.jdesktop.wonderland.common
Class ModuleURI

java.lang.Object
  extended by org.jdesktop.wonderland.common.AssetURI
      extended by org.jdesktop.wonderland.common.ModuleURI
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ArtURI, JarURI

public abstract class ModuleURI
extends AssetURI

The ModuleURI class uniquely identifies a resource within the sytem that is managed by the client-side asset management system. The format of a resource URI is:

://@:/

where refers to the specific kind of asset (e.g. 'wla' for art assets, 'wlj' for plugin assets), is the name of the module where the asset lives, and : is the server name from which the asset comes, and is the relative path of the asset in the module.

Author:
Jordan Slott
See Also:
Serialized Form

Constructor Summary
ModuleURI()
          Default constructor
ModuleURI(java.lang.String uri)
          Constructor which takes the string represents of the URI.
ModuleURI(java.lang.String protocol, java.lang.String moduleName, java.lang.String hostName, int hostPort, java.lang.String assetPath)
          Constructor, takes the components of the URI: protocol, module name, server name, port, and asset path
ModuleURI(java.lang.String protocol, java.lang.String moduleName, java.lang.String hostNameAndPort, java.lang.String assetPath)
          Construct, takes the components of the URI: protocol, module name, host name and port, and asset path.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Must Override equals() here -- a module URI is consider equal even if its host and port differ.
 java.lang.String getAssetPath()
          Returns the raw relative path of the asset, without prepending any assumed directory like "art/".
 java.lang.String getHostName()
          Returns the host name, null if none is set.
 int getHostPort()
          Returns the host port, -1 if none is set.
 java.lang.String getModuleName()
          Returns the module name off this URI.
 java.lang.String getProtocol()
          Returns the protocol of the URI
 java.lang.String getRelativeCachePath()
          Returns a relative path of the asset so that it exists in a unique location within a cache.
abstract  java.lang.String getRelativePathInModule()
          Returns the relative path of the resource specified by the URI within the module.
 java.lang.String getServerURL()
          Returns the base URL of the server as a string, or null if not present
 int hashCode()
          Must override hasCode() here -- the computation should not include the host name and port.
 void setServerHostAndPort(java.lang.String hostNameAndPort)
          Annotates this URI with a : based upon the current primary server.
 java.lang.String toExternalForm()
          Must override toExternalForm() to not include the host name and port.
 java.lang.String toString()
          Must override toString() to not equal toExternalForm().
 java.net.URL toURL()
          Returns a URL from the URI.
 
Methods inherited from class org.jdesktop.wonderland.common.AssetURI
getURI, uriFactory
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ModuleURI

public ModuleURI()
Default constructor


ModuleURI

public ModuleURI(java.lang.String uri)
          throws java.net.URISyntaxException
Constructor which takes the string represents of the URI.

Parameters:
uri - The string URI representation
Throws:
java.net.URISyntaxException

ModuleURI

public ModuleURI(java.lang.String protocol,
                 java.lang.String moduleName,
                 java.lang.String hostName,
                 int hostPort,
                 java.lang.String assetPath)
Constructor, takes the components of the URI: protocol, module name, server name, port, and asset path


ModuleURI

public ModuleURI(java.lang.String protocol,
                 java.lang.String moduleName,
                 java.lang.String hostNameAndPort,
                 java.lang.String assetPath)
Construct, takes the components of the URI: protocol, module name, host name and port, and asset path. The host name and port is given as: :

Method Detail

toURL

public java.net.URL toURL()
                   throws java.net.MalformedURLException
Returns a URL from the URI.

Specified by:
toURL in class AssetURI
Returns:
A URL
Throws:
java.net.MalformedURLException

getModuleName

public java.lang.String getModuleName()
Returns the module name off this URI.

Returns:
The module name

getAssetPath

public java.lang.String getAssetPath()
Returns the raw relative path of the asset, without prepending any assumed directory like "art/". It has no leading "/". This method should return all forward-slashes.


getProtocol

public java.lang.String getProtocol()
Returns the protocol of the URI

Overrides:
getProtocol in class AssetURI

getHostPort

public int getHostPort()
Returns the host port, -1 if none is set.

Returns:
The host port

getHostName

public java.lang.String getHostName()
Returns the host name, null if none is set.

Returns:
The host name

getServerURL

public java.lang.String getServerURL()
Returns the base URL of the server as a string, or null if not present

Returns:
The base server URL

setServerHostAndPort

public void setServerHostAndPort(java.lang.String hostNameAndPort)
Description copied from class: AssetURI
Annotates this URI with a : based upon the current primary server. This method is implemented by subclasses who need a reference to the current server in order to resolve the asset. For URIs that do not need this information, this method does nothing.

Specified by:
setServerHostAndPort in class AssetURI
Parameters:
hostNameAndPort - The host name and port to annotate the URI with

toString

public java.lang.String toString()
Must override toString() to not equal toExternalForm(). In this case, toString() will return the URI with the host name and port for display purposes.

Overrides:
toString in class AssetURI
Returns:
The string representation of the URI

toExternalForm

public java.lang.String toExternalForm()
Must override toExternalForm() to not include the host name and port. This method is used to generate a string representation to use in the asset cache. In the case of federation, even if the host name and port differ, they are considered the same for asset purposes.

Overrides:
toExternalForm in class AssetURI
Returns:
The external URI form

equals

public boolean equals(java.lang.Object obj)
Must Override equals() here -- a module URI is consider equal even if its host and port differ. In the case of federation, even if the same uri has different host name and ports, they are considered the same if all other attributes are equal.

Overrides:
equals in class AssetURI

hashCode

public int hashCode()
Must override hasCode() here -- the computation should not include the host name and port.

Overrides:
hashCode in class AssetURI

getRelativePathInModule

public abstract java.lang.String getRelativePathInModule()
Returns the relative path of the resource specified by the URI within the module. The relative path does not being with any forward "/". This method adds any directories before the relative asset path. This method should return all forward-slashes.

Returns:
The relative path within the URI

getRelativeCachePath

public java.lang.String getRelativeCachePath()
Returns a relative path of the asset so that it exists in a unique location within a cache. The path does not have a leading "/".

Specified by:
getRelativeCachePath in class AssetURI
Returns:
A unique relative path for the URI


Open Wonderland - http://openwonderland.org