Package com.jbstrap.core.cache
Enum Class DownloadCache
- All Implemented Interfaces:
Serializable
,Comparable<DownloadCache>
,Constable
This cache is used to store temporary data required for the download process
The files stored in the cache will be able to be downloaded on the UI, using the cache ID.
The files stored in the cache will be deleted, if the user has downloaded them, or after a certain time has passed.
This timeout can be specified by using the following:
DOWNLOAD_LINK_EXPIRATION_TIME
By default, the timeout is 3 minutes.
- Since:
- 4.0
- Author:
- JBStrap
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds a file to the cacheAdds a file to the cacheAdds a file to the cachebyte[]
getFileContent
(String id) Gets the file content, by using the cache IDgetFileName
(String id) Gets the filename, by using the cache IDgetFileStream
(String id) Gets the file input stream, by using the cache IDvoid
Removes the specified file from the cache.static DownloadCache
Returns the enum constant of this class with the specified name.static DownloadCache[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
INSTANCE
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
addFile
Adds a file to the cache- Parameters:
fileName
- The filename. The name must be specified, or aNullPointerException
will be throwndata
- The string data from which will be generated the file- Returns:
- The cache ID, which is used as a refer to the file for the download process
- Throws:
NullPointerException
- If the file name is not specified
-
addFile
Adds a file to the cache- Parameters:
fileName
- The filename. The name must be specifiedfileBody
- The file content in a byte array. If not specified, the downloaded file will be empty.- Returns:
- The cache ID, which is used as a refer to the file for the download process
- Throws:
NullPointerException
- If the file name is not specified
-
addFile
Adds a file to the cache- Parameters:
fileName
- The filename. The name must be specified, or aNullPointerException
will be thrownfile
- The file, specified as aFile
. The specified file must be readable by the system- Returns:
- The cache ID, which is used as a reference to the file for the download process
- Throws:
NullPointerException
- If the file name is not specified
-
getFileName
Gets the filename, by using the cache ID- Parameters:
id
- The cache ID, which is generated when a file is loaded into the cache- Returns:
- The filename or
null
, if the specified file is not found
-
getFileContent
Gets the file content, by using the cache ID- Parameters:
id
- The cache ID, which is generated when a file is loaded into the cache- Returns:
- The file contents in a byte array or
null
, if the file is not found
-
getFileStream
Gets the file input stream, by using the cache ID- Parameters:
id
- The cache ID, which is generated when a file is loaded into the cache- Returns:
- The file input stream or
null
, if the file is not found
-
remove
Removes the specified file from the cache. If there is no file assigned to the specified ID, the method won't do anything.- Parameters:
id
- The cache ID, which is generated when a file is loaded into the cache
-