Package de.xima.fc.common.data.file
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 ofISerializableFilewith several static factory methods for creating instances.- Since:
- 8.2.0
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcontentType()Gets the content type (mime type) of the file.ISerializableInputStreamSupplierdata()Gets the binary data of the file.static ISerializableFileemptySerializableFile(String fileName, String contentType)Creates an empty serializable file with the given file name and content type.StringfileName()Gets the name of the file.longfileSize()Gets the size of the file in bytes.static ISerializableFileserializableFile(String fileName, String contentType, byte[] data)Creates a serializable file with the given file name, content type and data.static ISerializableFileserializableFile(String fileName, String contentType, long fileSize, ISerializableInputStreamSupplier data)Creates a serializable file with the given file name, content type and data.static ISerializableFileserializableFile(String fileName, String contentType, File data)Creates a serializable file with the given file name, content type and data.static ISerializableFileserializableFile(String fileName, String contentType, InputStream data)Creates a serializable file with the given file name, content type and data.static ISerializableFileserializableFile(String fileName, String contentType, String textData, Charset charset)Creates a serializable file with the given file name, content type and data.static ISerializableFileserializableFile(String fileName, String contentType, Path data)Creates a serializable file with the given file name, content type and data.
-
-
-
Method Detail
-
contentType
public String contentType()
Description copied from interface:ISerializableFileGets the content type (mime type) of the file.- Specified by:
contentTypein interfaceISerializableFile- Returns:
- The content type of the file.
-
data
public ISerializableInputStreamSupplier data()
Description copied from interface:ISerializableFileGets the binary data of the file. Must not be null and contain at least one byte.- Specified by:
datain interfaceISerializableFile- Returns:
- The binary data of the file.
-
fileName
public String fileName()
Description copied from interface:ISerializableFileGets the name of the file. Must not be blank.- Specified by:
fileNamein interfaceISerializableFile- Returns:
- The name of the file.
-
fileSize
public long fileSize()
Description copied from interface:ISerializableFileGets the size of the file in bytes.- Specified by:
fileSizein interfaceISerializableFile- 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
-
-