Class DefaultSerializableFile
java.lang.Object
de.xima.fc.common.data.file.DefaultSerializableFile
- All Implemented Interfaces:
ISerializableFile, Serializable
Default implementation of
ISerializableFile with several static factory methods for creating instances.- Since:
- 8.2.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionGets the content type (mime type) of the file.data()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.fileName()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 Details
-
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
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
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
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
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
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
-