org.jdesktop.wonderland.client.assetmgr
Class Asset<T>

java.lang.Object
  extended by org.jdesktop.wonderland.client.assetmgr.Asset<T>
Direct Known Subclasses:
AssetFile

public abstract class Asset<T>
extends java.lang.Object

The Asset class represents an asset (e.g. artwork) in the system. An asset is uniquely identified by a combination of its URI (see AssetURI class) and an optional checksum. Assets with no checksum are considered the same asset.

Each asset has a type: typically, either file, image, or model and given by the AssetType enumeration.

The url gives the full URL from which the asset was downloaded

Author:
paulby, Jordan Slott

Nested Class Summary
static class Asset.Status
           
 
Field Summary
protected  AssetURI assetURI
           
protected  java.lang.String baseURL
           
protected  java.lang.String checksum
           
protected  java.io.File localCacheFile
           
protected  AssetType type
           
 
Constructor Summary
Asset(AssetID assetID)
          Constructor that takes the unique URI as an argument.
 
Method Summary
 void addAssetProgressListener(AssetManager.AssetProgressListener listener)
           
protected  void fireStatusChanged(Asset.Status status)
           
abstract  T getAsset()
          Return the asset
 AssetURI getAssetURI()
          Returns the unique URI describing the asset.
 java.lang.String getBaseURL()
          Returns the base URL from which the asset was downloaded, null if unknown
 java.lang.String getChecksum()
          Get the checksum of this file in the local cache.
 int getDownloadBytes()
           
 int getDownloadPercent()
           
 java.lang.String getFailureInfo()
           
 java.io.File getLocalCacheFile()
          Return the file containing the local cache of the asset
 java.net.URL getLocalCacheFileAsURL()
          Returns the local cache file as a URL, or null if the asset is not cached.
 Asset.Status getStatus()
           
 AssetType getType()
          Returns the asset type, typically either a file, image, or model.
 void removeAssetProgressListener(AssetManager.AssetProgressListener listener)
           
protected  void setDownloadFailure(java.lang.String failureInfo)
           
protected  void setDownloadProgress(int downloadBytes, int downloadPercent)
           
protected  void setDownloadSuccess()
           
protected  void setStatus(Asset.Status status)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

protected AssetType type

assetURI

protected AssetURI assetURI

localCacheFile

protected java.io.File localCacheFile

checksum

protected java.lang.String checksum

baseURL

protected java.lang.String baseURL
Constructor Detail

Asset

public Asset(AssetID assetID)
Constructor that takes the unique URI as an argument.

Parameters:
assetURI - The unique identifying asset URI.
Method Detail

getType

public AssetType getType()
Returns the asset type, typically either a file, image, or model.

Returns:
The type of asset

getAssetURI

public AssetURI getAssetURI()
Returns the unique URI describing the asset.

Returns:
The unique URI describing the asset

getLocalCacheFile

public java.io.File getLocalCacheFile()
Return the file containing the local cache of the asset

Returns:

getLocalCacheFileAsURL

public java.net.URL getLocalCacheFileAsURL()
                                    throws java.net.MalformedURLException
Returns the local cache file as a URL, or null if the asset is not cached.

Returns:
The local cache file as a URL
Throws:
java.net.MalformedURLException

getChecksum

public java.lang.String getChecksum()
Get the checksum of this file in the local cache.

Returns:

getBaseURL

public java.lang.String getBaseURL()
Returns the base URL from which the asset was downloaded, null if unknown

Returns:
The base URL

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getAsset

public abstract T getAsset()
Return the asset

Returns:

addAssetProgressListener

public void addAssetProgressListener(AssetManager.AssetProgressListener listener)

removeAssetProgressListener

public void removeAssetProgressListener(AssetManager.AssetProgressListener listener)

fireStatusChanged

protected void fireStatusChanged(Asset.Status status)

getStatus

public Asset.Status getStatus()

setStatus

protected void setStatus(Asset.Status status)

setDownloadProgress

protected void setDownloadProgress(int downloadBytes,
                                   int downloadPercent)

getDownloadBytes

public int getDownloadBytes()

getDownloadPercent

public int getDownloadPercent()

setDownloadSuccess

protected void setDownloadSuccess()

getFailureInfo

public java.lang.String getFailureInfo()

setDownloadFailure

protected void setDownloadFailure(java.lang.String failureInfo)


Open Wonderland - http://openwonderland.org