Enum Class DownloadCache

java.lang.Object
java.lang.Enum<DownloadCache>
com.jbstrap.core.cache.DownloadCache
All Implemented Interfaces:
Serializable, Comparable<DownloadCache>, Constable

public enum DownloadCache extends Enum<DownloadCache>

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
  • Enum Constant Details

  • Method Details

    • values

      public static DownloadCache[] 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

      public static DownloadCache valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • addFile

      public String addFile(String fileName, String data)
      Adds a file to the cache
      Parameters:
      fileName - The filename. The name must be specified, or a NullPointerException will be thrown
      data - 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

      public String addFile(String fileName, byte[] fileBody)
      Adds a file to the cache
      Parameters:
      fileName - The filename. The name must be specified
      fileBody - 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

      public String addFile(String fileName, File file)
      Adds a file to the cache
      Parameters:
      fileName - The filename. The name must be specified, or a NullPointerException will be thrown
      file - The file, specified as a File. 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

      public String getFileName(String id)
      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

      public byte[] getFileContent(String id)
      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

      public InputStream getFileStream(String id)
      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

      public void remove(String id)
      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