org.jdesktop.wonderland.common
Class ContentURI

java.lang.Object
  extended by org.jdesktop.wonderland.common.AssetURI
      extended by org.jdesktop.wonderland.common.ContentURI
All Implemented Interfaces:
java.io.Serializable

public class ContentURI
extends AssetURI

The ContentURI class uniquely identifies a resource within the content repository.

Author:
Jordan Slott
See Also:
Serialized Form

Constructor Summary
ContentURI(java.lang.String uri)
          Constructor which takes the string represents of the URI.
ContentURI(java.lang.String protocol, java.lang.String root, java.lang.String hostName, int hostPort, java.lang.String assetPath)
          Constructor, takes the components of the URI: protocol, server name and port, root, and asset path
ContentURI(java.lang.String protocol, java.lang.String root, java.lang.String hostNameAndPort, java.lang.String assetPath)
          Construct, takes the components of the URI: protocol, root name, host name and port, and asset path.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 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 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.
 java.lang.String getRelativePath()
          Returns the relative resource path beneath some base repository URL
 java.lang.String getRoot()
          Returns the root repository name of this URI.
 int hashCode()
           
 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

ContentURI

public ContentURI(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

ContentURI

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


ContentURI

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

Method Detail

getRoot

public java.lang.String getRoot()
Returns the root repository name of this URI.

Returns:
The root 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 "/".


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

getRelativePath

public java.lang.String getRelativePath()
Returns the relative resource path beneath some base repository URL


getRelativeCachePath

public java.lang.String getRelativeCachePath()
Description copied from class: AssetURI
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 "/". This method should return either forward or backward slashes depending upon the platform.

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

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

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

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

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class AssetURI

hashCode

public int hashCode()
Overrides:
hashCode in class AssetURI


Open Wonderland - http://openwonderland.org