com.vaadin.terminal.
Class StreamResource
java.lang.Object
com.vaadin.terminal.StreamResource
All Implemented Interfaces:
- extends Object
- implements ApplicationResource
public class StreamResource
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:
6.8.18
Author:
Vaadin Ltd.
See Also:
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)
- Parameters:
streamSource
- the source Stream.filename
- the name of the file.application
- the Application object.
Creates a new stream resource for downloading from stream.
Method Detail |
---|
getMIMEType
public String getMIMEType()
- Specified by:
getMIMEType
in interfaceResource
- Returns:
- the MIME type of the resource.
- See Also:
Resource.getMIMEType()
Description copied from interface: Resource
Gets the MIME type of the resource.
setMIMEType
public void setMIMEType(String MIMEType)
- Parameters:
MIMEType
- the MIME type to be set.
Sets the mime type of the resource.
getStreamSource
public StreamResource.StreamSource getStreamSource()
- Returns:
- Source of the StreamResource.
Returns the source for this StreamResource
. StreamSource is
queried when the resource is about to be streamed to the client.
setStreamSource
public void setStreamSource(StreamResource.StreamSource streamSource)
- Parameters:
streamSource
- the source to set.
Sets the source for this StreamResource
.
StreamSource
is queried when the resource is about to be
streamed to the client.
getFilename
public String getFilename()
- Specified by:
getFilename
in interfaceApplicationResource
- Returns:
- the filename.
Gets the filename.
setFilename
public void setFilename(String filename)
- Parameters:
filename
- the filename to set.
Sets the filename.
getApplication
public Application getApplication()
- Specified by:
getApplication
in interfaceApplicationResource
- See Also:
ApplicationResource.getApplication()
Description copied from interface: ApplicationResource
Gets the application of the resource.
getStream
public DownloadStream getStream()
- Specified by:
getStream
in interfaceApplicationResource
- See Also:
ApplicationResource.getStream()
Description copied from interface: ApplicationResource
Gets resource as stream.
getBufferSize
public int getBufferSize()
- Specified by:
getBufferSize
in interfaceApplicationResource
- Returns:
- int the size of the buffer in bytes.
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.
setBufferSize
public void setBufferSize(int bufferSize)
- Parameters:
bufferSize
- the size of the buffer in bytes.
Sets the size of the download buffer used for this resource.
getCacheTime
public long getCacheTime()
- Specified by:
getCacheTime
in interfaceApplicationResource
- Returns:
- Cache time in milliseconds
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
.
setCacheTime
public void setCacheTime(long cacheTime)
- Parameters:
cacheTime
- the cache time in milliseconds.
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.