org.jdesktop.wonderland.client.assetmgr.content
Class WlContentAssetStream

java.lang.Object
  extended by org.jdesktop.wonderland.client.assetmgr.AssetStream
      extended by org.jdesktop.wonderland.client.assetmgr.content.WlContentAssetStream

public class WlContentAssetStream
extends AssetStream

An asset stream for assets served by web servers via http.

Author:
Jordan Slott

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jdesktop.wonderland.client.assetmgr.AssetStream
AssetStream.AssetResponse
 
Field Summary
 
Fields inherited from class org.jdesktop.wonderland.client.assetmgr.AssetStream
logger
 
Constructor Summary
WlContentAssetStream(AssetStream.AssetResponse response, AssetURI uri)
          Constructor that take the response code and uri of the asset.
WlContentAssetStream(AssetStream.AssetResponse response, AssetURI uri, java.net.URLConnection urlConnection, java.lang.String baseURL)
          Constructor that take the response code, uri of the asset and base URL from which to download the asset.
 
Method Summary
 void close()
          Invoked when the user of this class is done reading data from the stream and wants the AssetStream to do any cleanup.
 AssetCache.CachePolicy getCachePolicy()
          Returns the desired cache policy for the asset: whether to allow multiple copies of the same asset uri or only a single instance.
 java.lang.String getChecksum()
          Returns the asset checksum (a string that identifies the asset) after the open() method has been called.
 int getContentLength()
          Returns the length of the content (bytes) in the stream.
 java.io.InputStream getInputStream()
          Returns an input stream suitable to read the data, or null if the asset is already cached or the repository contains invalid data.
 void open()
          Opens the asset stream for reading.
 
Methods inherited from class org.jdesktop.wonderland.client.assetmgr.AssetStream
getAssetURI, getBaseURL, getResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WlContentAssetStream

public WlContentAssetStream(AssetStream.AssetResponse response,
                            AssetURI uri)
Constructor that take the response code and uri of the asset. Also takes the last modification date of the asset currently known.


WlContentAssetStream

public WlContentAssetStream(AssetStream.AssetResponse response,
                            AssetURI uri,
                            java.net.URLConnection urlConnection,
                            java.lang.String baseURL)
Constructor that take the response code, uri of the asset and base URL from which to download the asset.

Method Detail

getCachePolicy

public AssetCache.CachePolicy getCachePolicy()
Description copied from class: AssetStream
Returns the desired cache policy for the asset: whether to allow multiple copies of the same asset uri or only a single instance.

Specified by:
getCachePolicy in class AssetStream
Returns:
The CachePolicy

getInputStream

public java.io.InputStream getInputStream()
Description copied from class: AssetStream
Returns an input stream suitable to read the data, or null if the asset is already cached or the repository contains invalid data.

Specified by:
getInputStream in class AssetStream
Returns:
An InputStream object

open

public void open()
Description copied from class: AssetStream
Opens the asset stream for reading. This method must be called before getInputStream(), getChecksum(), and getContentLength() methods.

Specified by:
open in class AssetStream

close

public void close()
Description copied from class: AssetStream
Invoked when the user of this class is done reading data from the stream and wants the AssetStream to do any cleanup.

Specified by:
close in class AssetStream

getContentLength

public int getContentLength()
Description copied from class: AssetStream
Returns the length of the content (bytes) in the stream. Returns -1 if the content lenght is not know. This method must be called after the open() method is invoked.

Specified by:
getContentLength in class AssetStream
Returns:
The length of content in the stream.

getChecksum

public java.lang.String getChecksum()
Description copied from class: AssetStream
Returns the asset checksum (a string that identifies the asset) after the open() method has been called.

Specified by:
getChecksum in class AssetStream
Returns:
A String checksum


Open Wonderland - http://openwonderland.org