public class ClassResource extends Object implements ConnectorResource
ClassResource
is a named resource accessed with the class
loader.
This can be used to access resources such as icons, files, etc.Class.getResource(java.lang.String)
,
Serialized FormCONNECTOR_PATH
Constructor and Description |
---|
ClassResource(Class<?> associatedClass,
String resourceName)
Creates a new application resource instance.
|
ClassResource(String resourceName)
Creates a new application resource instance.
|
Modifier and Type | Method and Description |
---|---|
protected Class<?> |
getAssociatedClass() |
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 virtual filename for this resource.
|
String |
getMIMEType()
Gets the MIME type of this resource.
|
DownloadStream |
getStream()
Gets resource as stream.
|
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.
|
public ClassResource(String resourceName)
resourceName
- the Unique identifier of the resource within the application.public String getMIMEType()
getMIMEType
in interface Resource
Resource.getMIMEType()
public String getFilename()
ConnectorResource
getFilename
in interface ConnectorResource
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
protected Class<?> getAssociatedClass()
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.getBufferSize()
public long getCacheTime()
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 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.