Class DefaultSerializableFile

java.lang.Object
de.xima.fc.common.data.file.DefaultSerializableFile
All Implemented Interfaces:
ISerializableFile, Serializable

public final class DefaultSerializableFile extends Object implements ISerializableFile
Default implementation of ISerializableFile with several static factory methods for creating instances.
Since:
8.2.0
See Also:
  • Method Details

    • contentType

      public String contentType()
      Description copied from interface: ISerializableFile
      Gets the content type (mime type) of the file.
      Specified by:
      contentType in interface ISerializableFile
      Returns:
      The content type of the file.
    • data

      Description copied from interface: ISerializableFile
      Gets the binary data of the file. Must not be null and contain at least one byte.
      Specified by:
      data in interface ISerializableFile
      Returns:
      The binary data of the file.
    • fileName

      public String fileName()
      Description copied from interface: ISerializableFile
      Gets the name of the file. Must not be blank.
      Specified by:
      fileName in interface ISerializableFile
      Returns:
      The name of the file.
    • fileSize

      public long fileSize()
      Description copied from interface: ISerializableFile
      Gets the size of the file in bytes.
      Specified by:
      fileSize in interface ISerializableFile
      Returns:
      The size of the file in bytes.
    • emptySerializableFile

      public static ISerializableFile emptySerializableFile(String fileName, String contentType)
      Creates an empty serializable file with the given file name and content type.
      Parameters:
      fileName - The name of the file.
      contentType - The content type of the file.
      Returns:
      An empty serializable file with the given file name and content type.
    • serializableFile

      public static ISerializableFile serializableFile(String fileName, String contentType, File data)
      Creates a serializable file with the given file name, content type and data.
      Parameters:
      fileName - The name of the file.
      contentType - The content type of the file.
      data - The data of the file.
      Returns:
      A serializable file with the given file name, content type and data.
    • serializableFile

      public static ISerializableFile serializableFile(String fileName, String contentType, Path data) throws IOException
      Creates a serializable file with the given file name, content type and data.
      Parameters:
      fileName - The name of the file.
      contentType - The content type of the file.
      data - The data of the file.
      Returns:
      A serializable file with the given file name, content type and data.
      Throws:
      IOException
    • serializableFile

      public static ISerializableFile serializableFile(String fileName, String contentType, byte[] data)
      Creates a serializable file with the given file name, content type and data.
      Parameters:
      fileName - The name of the file.
      contentType - The content type of the file.
      data - The data of the file.
      Returns:
      A serializable file with the given file name, content type and data.
    • serializableFile

      public static ISerializableFile serializableFile(String fileName, String contentType, String textData, Charset charset)
      Creates a serializable file with the given file name, content type and data.
      Parameters:
      fileName - The name of the file.
      contentType - The content type of the file.
      textData - The text data of the file.
      charset - The charset of the text data.
      Returns:
      A serializable file with the given file name, content type and data.
    • serializableFile

      public static ISerializableFile serializableFile(String fileName, String contentType, long fileSize, ISerializableInputStreamSupplier data)
      Creates a serializable file with the given file name, content type and data.
      Parameters:
      fileName - The name of the file.
      contentType - The content type of the file.
      fileSize - The size of the file in bytes.
      data - The data of the file.
      Returns:
      A serializable file with the given file name, content type and data.
    • serializableFile

      public static ISerializableFile serializableFile(String fileName, String contentType, InputStream data) throws IOException
      Creates a serializable file with the given file name, content type and data. Note that since the instance must be serializable, the data from the input stream will be read into memory.
      Parameters:
      fileName - The name of the file.
      contentType - The content type of the file.
      data - The data of the file.
      Returns:
      A serializable file with the given file name, content type and data.
      Throws:
      IOException