com.vaadin.terminal.
Class FileResource
java.lang.Object
com.vaadin.terminal.FileResource
All Implemented Interfaces:
- extends Object
- implements ApplicationResource
public class FileResource
FileResources
are files or directories on local filesystem. The
files and directories are served through URI:s to the client terminal and
thus must be registered to an URI context before they can be used. The
resource is automatically registered to the application when it is created.
Since:
3.0
Version:
6.8.18
Author:
Vaadin Ltd.
See Also:
Field Summary |
---|
Fields inherited from interface com.vaadin.terminal.ApplicationResource |
---|
DEFAULT_CACHETIME |
Constructor Summary | |
---|---|
FileResource(File sourceFile,
Application application)
Creates a new file resource for providing given file for client terminals. |
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 virtual filename for this resource. |
String |
getMIMEType()
Gets the MIME type of the resource. |
File |
getSourceFile()
Gets the source file. |
DownloadStream |
getStream()
Gets the 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. |
void |
setSourceFile(File sourceFile)
Sets the source file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
FileResource
public FileResource(File sourceFile,
Application application)
Creates a new file resource for providing given file for client terminals.
Method Detail |
---|
getStream
public DownloadStream getStream()
- Specified by:
getStream
in interfaceApplicationResource
- See Also:
ApplicationResource.getStream()
Gets the resource as stream.
getSourceFile
public File getSourceFile()
- Returns:
- the source File.
Gets the source file.
setSourceFile
public void setSourceFile(File sourceFile)
- Parameters:
sourceFile
- the source file to set.
Sets the source file.
getApplication
public Application getApplication()
- Specified by:
getApplication
in interfaceApplicationResource
- See Also:
ApplicationResource.getApplication()
Description copied from interface: ApplicationResource
Gets the application of the resource.
getFilename
public String getFilename()
- Specified by:
getFilename
in interfaceApplicationResource
- Returns:
- the file name associated to this resource.
- See Also:
ApplicationResource.getFilename()
Description copied from interface: ApplicationResource
Gets the virtual filename for this resource.
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.
getCacheTime
public long getCacheTime()
- Specified by:
getCacheTime
in interfaceApplicationResource
- Returns:
- Cache time in milliseconds.
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
DownloadStream.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.
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.