public class StreamResource extends Object implements ConnectorResource
StreamResource
is a resource provided to the client directly by
the application.Modifier and Type | Class and Description |
---|---|
static interface |
StreamResource.StreamSource
Interface implemented by the source of a StreamResource.
|
CONNECTOR_PATH
Constructor and Description |
---|
StreamResource(StreamResource.StreamSource streamSource,
String filename)
Creates a new stream resource for downloading from stream.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
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 . |
int |
hashCode() |
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 . |
public StreamResource(StreamResource.StreamSource streamSource, String filename)
streamSource
- the source Stream.filename
- the name of the file.public String getMIMEType()
Resource
getMIMEType
in interface Resource
Resource.getMIMEType()
public void setMIMEType(String mimeType)
mimeType
- the MIME type to be set.public StreamResource.StreamSource getStreamSource()
StreamResource
. StreamSource is
queried when the resource is about to be streamed to the client.public void setStreamSource(StreamResource.StreamSource streamSource)
StreamResource
.
StreamSource
is queried when the resource is about to be
streamed to the client.streamSource
- the source to set.public String getFilename()
getFilename
in interface ConnectorResource
public void setFilename(String filename)
filename
- the filename to set.public DownloadStream getStream()
ConnectorResource
Note that this method is called while the session is locked to prevent
race conditions but the methods in the returned DownloadStream
are assumed to be unrelated to the VaadinSession and are called without
holding session locks (to prevent locking the session during long file
downloads).
getStream
in interface ConnectorResource
public int getBufferSize()
If the buffer size is 0, the buffer size is decided by the terminal adapter. The default value is 0.
public void setBufferSize(int bufferSize)
bufferSize
- the size of the buffer in bytes.public long getCacheTime()
DownloadStream.DEFAULT_CACHETIME
.public void setCacheTime(long cacheTime)
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 negative value disables the caching of this stream.
cacheTime
- the cache time in milliseconds.Copyright © 2018 Vaadin Ltd. All rights reserved.