com.vaadin.terminal
Class StreamResource

java.lang.Object
  extended by com.vaadin.terminal.StreamResource
All Implemented Interfaces:
ApplicationResource, Resource, Serializable

public class StreamResource
extends Object
implements ApplicationResource

StreamResource is a resource provided to the client directly by the application. The strean resource is fetched from URI that is most often in the context of the application or window. The resource is automatically registered to window in creation.

Since:
3.0
Version:
7.0.0.alpha3
Author:
Vaadin Ltd.
See Also:
Serialized Form

Nested Class Summary
static interface StreamResource.StreamSource
          Interface implemented by the source of a StreamResource.
 
Field Summary
 
Fields inherited from interface com.vaadin.terminal.ApplicationResource
DEFAULT_CACHETIME
 
Constructor Summary
StreamResource(StreamResource.StreamSource streamSource, String filename, Application application)
          Creates a new stream resource for downloading from stream.
 
Method Summary
 Application getApplication()
          Gets the application of the resource.
 int getBufferSize()
          Gets the size of the download buffer used for this resource.
 long getCacheTime()
          Gets the length of cache expiration time.
 String getFilename()
          Gets the filename.
 String getMIMEType()
          Gets the MIME type of the resource.
 DownloadStream getStream()
          Gets resource as stream.
 StreamResource.StreamSource getStreamSource()
          Returns the source for this StreamResource.
 void setBufferSize(int bufferSize)
          Sets the size of the download buffer used for this resource.
 void setCacheTime(long cacheTime)
          Sets the length of cache expiration time.
 void setFilename(String filename)
          Sets the filename.
 void setMIMEType(String MIMEType)
          Sets the mime type of the resource.
 void setStreamSource(StreamResource.StreamSource streamSource)
          Sets the source for this StreamResource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamResource

public StreamResource(StreamResource.StreamSource streamSource,
                      String filename,
                      Application application)
Creates a new stream resource for downloading from stream.

Parameters:
streamSource - the source Stream.
filename - the name of the file.
application - the Application object.
Method Detail

getMIMEType

public String getMIMEType()
Description copied from interface: Resource
Gets the MIME type of the resource.

Specified by:
getMIMEType in interface Resource
Returns:
the MIME type of the resource.
See Also:
Resource.getMIMEType()

setMIMEType

public void setMIMEType(String MIMEType)
Sets the mime type of the resource.

Parameters:
MIMEType - the MIME type to be set.

getStreamSource

public StreamResource.StreamSource getStreamSource()
Returns the source for this StreamResource. StreamSource is queried when the resource is about to be streamed to the client.

Returns:
Source of the StreamResource.

setStreamSource

public void setStreamSource(StreamResource.StreamSource streamSource)
Sets the source for this StreamResource. StreamSource is queried when the resource is about to be streamed to the client.

Parameters:
streamSource - the source to set.

getFilename

public String getFilename()
Gets the filename.

Specified by:
getFilename in interface ApplicationResource
Returns:
the filename.

setFilename

public void setFilename(String filename)
Sets the filename.

Parameters:
filename - the filename to set.

getApplication

public Application getApplication()
Description copied from interface: ApplicationResource
Gets the application of the resource.

Specified by:
getApplication in interface ApplicationResource
See Also:
ApplicationResource.getApplication()

getStream

public DownloadStream getStream()
Description copied from interface: ApplicationResource
Gets resource as stream.

Specified by:
getStream in interface ApplicationResource
See Also:
ApplicationResource.getStream()

getBufferSize

public int getBufferSize()
Description copied from interface: ApplicationResource
Gets the size of the download buffer used for this resource.

If the buffer size is 0, the buffer size is decided by the terminal adapter. The default value is 0.

Specified by:
getBufferSize in interface ApplicationResource
Returns:
int the size of the buffer in bytes.

setBufferSize

public void setBufferSize(int bufferSize)
Sets the size of the download buffer used for this resource.

Parameters:
bufferSize - the size of the buffer in bytes.

getCacheTime

public long getCacheTime()
Description copied from interface: ApplicationResource
Gets the length of cache expiration time.

This gives the adapter the possibility cache streams sent to the client. The caching may be made in adapter or at the client if the client supports caching. Default is DEFAULT_CACHETIME.

Specified by:
getCacheTime in interface ApplicationResource
Returns:
Cache time in milliseconds

setCacheTime

public void setCacheTime(long cacheTime)
Sets the length of cache expiration time.

This gives the adapter the possibility cache streams sent to the client. The caching may be made in adapter or at the client if the client supports caching. Zero or negavive value disbales the caching of this stream.

Parameters:
cacheTime - the cache time in milliseconds.


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.