Package com.storedobject.common
Interface ContentGenerator
- All Known Subinterfaces:
BinaryContentGenerator,ImageGenerator,TextContentGenerator
- All Known Implementing Classes:
CSV,GeneratedImage,SVG
public interface ContentGenerator
Anything that generates some sort of "content".
- Author:
- Syam
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionMime type of the content.default StringFile extension normally used for this type of content.static StringgetFileExtension(String type) Determines the file extension based on the provided MIME type.
-
Field Details
-
ext
A map to store additional metadata or key-value pairs for content generation. The keys and values in this map are of type String. This field can be utilized to dynamically store and retrieve supplementary data associated with the content, such as configurations, attributes, or any other information relevant to the content being processed. Key considerations: - All keys and values must be non-null strings. - The map should be used in a thread-safe manner if accessed concurrently.
-
-
Method Details
-
getContentType
-
getFileExtension
File extension normally used for this type of content. The default implementation tries to guess the file extension from the mime type.- Returns:
- File extension without any prefix. Examples: "txt", "svg" etc.
-
getFileExtension
Determines the file extension based on the provided MIME type. The method applies a series of checks and mappings to deduce the correct file extension, or defaults to specific values when the MIME type does not match well-known patterns.- Parameters:
type- The MIME type of the content. Examples include "application/pdf", "audio/mpeg", or "image/jpeg". It can also be null.- Returns:
- The file extension corresponding to the given MIME type (e.g., "pdf", "mp3", "jpg"). Returns "bin" for null input or if no suitable extension is determined, and may return null for certain unmapped cases.
-