org.jdesktop.wonderland.client.assetmgr
Class AssetCache

java.lang.Object
  extended by org.jdesktop.wonderland.client.assetmgr.AssetCache

public class AssetCache
extends java.lang.Object

Manages the assets that are cached by the Asset Manager.

Author:
Jordan Slott

Nested Class Summary
static class AssetCache.CachePolicy
          Asset cache policy: SINGLE: Only a single copy of a uri is permitted in the cache MULTIPLE: Multiple copies of a uri are permitted in the cache
 
Constructor Summary
AssetCache(AssetFactory factory)
          Default constructor
 
Method Summary
 void addAsset(Asset asset, AssetCache.CachePolicy policy)
          Adds an asset to the cache, according to the given cache policy.
 void deleteAsset(Asset asset)
          Removes an asset from the cache.
 AssetDB getAssetDB()
          Returns the AssetDB associated with this asset manager
 java.util.List<Asset> getAssetList(AssetURI assetURI)
          Returns a list of assets for the given uri.
 java.lang.String getCacheDirectory()
          Returns the name of the directory in which the assets are cache.
 boolean isCached(AssetID assetID)
          Returns true if the given asset is cached, false if not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AssetCache

public AssetCache(AssetFactory factory)
           throws AssetDBException
Default constructor

Throws:
AssetDBException
Method Detail

getAssetDB

public AssetDB getAssetDB()
Returns the AssetDB associated with this asset manager

Returns:
An AssetDB object

getCacheDirectory

public java.lang.String getCacheDirectory()
Returns the name of the directory in which the assets are cache.

Returns:
The asset manager cache directory

isCached

public boolean isCached(AssetID assetID)
                 throws AssetCacheException
Returns true if the given asset is cached, false if not.

Parameters:
asset - The asset to check whether it is cached
Returns:
True if the asset is cached, false if not
Throws:
AssetCacheException

getAssetList

public java.util.List<Asset> getAssetList(AssetURI assetURI)
                                   throws AssetCacheException
Returns a list of assets for the given uri. Returns an empty list if none are present, throws AssetCacheException upon error

Parameters:
assetURI - The uri of the asset list to fetch
Returns:
A list of assets
Throws:
AssetCacheException - Upon error accessing the cache

addAsset

public void addAsset(Asset asset,
                     AssetCache.CachePolicy policy)
              throws AssetCacheException
Adds an asset to the cache, according to the given cache policy. This method assumes the asset has already been placed in the proper cache file.

Parameters:
asset - The asset to add to the cache
policy - The cache policy (SINGLE versus MULTIPLE)
Throws:
AssetCacheException

deleteAsset

public void deleteAsset(Asset asset)
                 throws AssetCacheException
Removes an asset from the cache. This the asset is not present, this method does nothing.

Parameters:
asset - The asset to remove from the cache
Throws:
AssetCacheException


Open Wonderland - http://openwonderland.org