/** * This file is auto generated from JavaDoc. Do not modify it manually. */ import type { String } from "../../types/java/lang/String"; import type { MimeTypeUtilConstants } from "../../types/senselogic/sitevision/api/render/velocity/VelocityAccess.MimeTypeUtilConstants"; /** * A utility that determines an appropriate MIME type for a file extension or vice versa. * *

* An instance of the Sitevision class implementing this interface can be obtained via {@link senselogic.sitevision.api.Utils#getMimeTypeUtil()}. * See {@link senselogic.sitevision.api.Utils} for how to obtain an instance of the Utils interface. *

* @author Magnus Lövgren * @since Sitevision 3.0 */ export interface MimeTypeUtil extends MimeTypeUtilConstants { /** * The generic application/octet-stream MIME type. * *

Would typically be appropriate to use as value for the fallback MIME type when using the * {@link #getMimeType(String, String)} whenever you require an acceptable, non-null MIME type to be returned.

*
    String mime = aMimeTypeUtil.getMimeType(anExtension, MimeTypeUtil.GENERIC_MIME_TYPE);
*/ GENERIC_MIME_TYPE: "application/octet-stream"; /** * Returns the MIME type appropriate for a specified file extension. * @param aFileExtensionExpression a file extension (e.g pdf) or an expression that ends with a period and a file extension (e.g myfile.pdf or http://www.xyz.com/files/myfile.pdf). Case insensitive. * @return a MIME type that matches the extension in aFileExtensionExpression, or null if extension is unknown * @see #getMimeType(String, String) */ getMimeType(aFileExtensionExpression: String | string): string; /** * Returns the MIME type (or a fallback MIME type) appropriate for a specified file extension. * @param aFileExtensionExpression a file extension (e.g pdf) or an expression that ends with a period and a file extension (e.g myfile.pdf or http://www.xyz.com/files/myfile.pdf). Case insensitive. * @param aFallbackMimeType the fallback MIME type to return if no MIME type can be found for aFileExtensionExpression * @return a MIME type that matches the extension in aFileExtensionExpression, or aFallbackMimeType if extension is unknown */ getMimeType( aFileExtensionExpression: String | string, aFallbackMimeType: String | string ): string; /** * Returns the file extension for a specified MIME type. * @param aMimeType a MIME type. Case insensitive. * @return the lowercased default file extension for MIME type aMimeType, or null if aMimeType is unknown or has no single well-known extension (e.g. application/octet-stream or text/plain) * @see #getExtension(String, String) */ getExtension(aMimeType: String | string): string; /** * Returns the file extension (or a fallback extension) for a specified MIME type. * @param aMimeType a MIME type. Case insensitive. * @param aFallbackExtension the fallback extension to return if no extension can be found for aMimeType * @return the lowercased default file extension for MIME type aMimeType, or aFallbackExtension if aMimeType is unknown or has no single well-known extension (e.g. application/octet-stream or text/plain) */ getExtension( aMimeType: String | string, aFallbackExtension: String | string ): string; /** * Checks if a specified file extension is an image type (according to its mapped MIME type). * *

* An image type has a MIME that starts with image/. *

* @param aFileExtensionExpression a file extension (e.g png) or an expression that ends with a period and a file extension (e.g myresource.png or http://www.xyz.com/files/myresource.png). Case insensitive. * @return true if aFileExtensionExpression is mapped to a image/* MIME type, false otherwise * @since Sitevision 4.0 */ isImageType(aFileExtensionExpression: String | string): boolean; /** * Checks if a specified file extension is a text type (according to its mapped MIME type). * *

* A text type has a MIME that starts with "text/". *

* @param aFileExtensionExpression a file extension (e.g txt) or an expression that ends with a period and a file extension (e.g myresource.txt or http://www.xyz.com/files/myresource.txt). Case insensitive. * @return true if aFileExtensionExpression is mapped to a text/* MIME type, false otherwise * @since Sitevision 4.1 */ isTextType(aFileExtensionExpression: String | string): boolean; /** * Checks if a specified file extension is a text type (according to its mapped MIME type). * *

* * A XML type typically has a MIME that starts with "application/" and ends with "xml". * This method will not include xml-based files covered by other categories (e.g. "office" types or the "svg" image type). * *

* @param aFileExtensionExpression a file extension (e.g xml) or an expression that ends with a period and a file extension (e.g myresource.xml or http://www.xyz.com/files/myresource.xml). Case insensitive. * @return true if aFileExtensionExpression is mapped to a application/*xml MIME type, false otherwise * @since Sitevision 4.1 */ isXmlType(aFileExtensionExpression: String | string): boolean; /** * Checks if a specified file extension is a video type (according to its mapped MIME type). * *

* A video type has a MIME that starts with "video/". *

* @param aFileExtensionExpression a file extension (e.g mov) or an expression that ends with a period and a file extension (e.g myresource.mov or http://www.xyz.com/files/myresource.mov). Case insensitive. * @return true if aFileExtensionExpression is mapped to a video/* MIME type, false otherwise * @since Sitevision 4.1 */ isVideoType(aFileExtensionExpression: String | string): boolean; /** * Checks if a specified file extension is a compressed/archive type (according to its mapped MIME type). * *

* Example of compressed MIME types: *

* * @param aFileExtensionExpression a file extension (e.g zip) or an expression that ends with a period and a file extension (e.g myresource.zip or http://www.xyz.com/files/myresource.zip). Case insensitive. * @return true if aFileExtensionExpression is mapped to a MIME type that is registered as compressed, false otherwise * @since Sitevision 4.1 */ isCompressedType(aFileExtensionExpression: String | string): boolean; /** * Checks if a specified file extension is a MS Word type (according to its mapped MIME type). * *

* Example of typical MS Word MIME types: *

* * @param aFileExtensionExpression a file extension (e.g doc) or an expression that ends with a period and a file extension (e.g myresource.doc or http://www.xyz.com/files/myresource.doc). Case insensitive. * @return true if aFileExtensionExpression is mapped to a MS Word MIME type, false otherwise * @since Sitevision 4.1 */ isMSWordType(aFileExtensionExpression: String | string): boolean; /** * Checks if a specified file extension is a MS Excel type (according to its mapped MIME type). * *

* Example of typical MS Excel MIME types: *

* * @param aFileExtensionExpression a file extension (e.g xls) or an expression that ends with a period and a file extension (e.g myresource.xls or http://www.xyz.com/files/myresource.xls). Case insensitive. * @return true if aFileExtensionExpression is mapped to a MS Excel MIME type, false otherwise * @since Sitevision 4.1 */ isMSExcelType(aFileExtensionExpression: String | string): boolean; /** * Checks if a specified file extension is a MS Powerpoint type (according to its mapped MIME type). * *

* Example of typical MS Powerpoint MIME types: *

* * @param aFileExtensionExpression a file extension (e.g ppt) or an expression that ends with a period and a file extension (e.g myresource.ppt or http://www.xyz.com/files/myresource.ppt). Case insensitive. * @return true if aFileExtensionExpression is mapped to a MS Powerpoint MIME type, false otherwise * @since Sitevision 4.1 */ isMSPowerpointType(aFileExtensionExpression: String | string): boolean; /** * Checks if a specified file extension is a MS Office type (according to its mapped MIME type). * *

* * This is a convenience method that checks if aFileExtensionExpression is mapped to a MS Word/Excel/Powerpoint MIME type. * (i.e. a combination of {@link #isMSWordType(String)}, {@link #isMSExcelType(String)} and {@link #isMSPowerpointType(String)}) * *

* @param aFileExtensionExpression a file extension (e.g doc) or an expression that ends with a period and a file extension (e.g myresource.xls or http://www.xyz.com/files/myresource.ppt). Case insensitive. * @return true if aFileExtensionExpression is mapped to a MS Word/Excel/Powerpoint MIME type, false otherwise * @since Sitevision 4.1 */ isMSOfficeType(aFileExtensionExpression: String | string): boolean; /** * Checks if a specified file extension is a font type (according to its mapped MIME type). * *

* Example of typical font MIME types: *

* * @param aFileExtensionExpression a file extension (e.g woff2) or an expression that ends with a period and a file extension (e.g myresource.woff2 or http://www.xyz.com/files/myresource.woff2). Case insensitive. * @return true if aFileExtensionExpression is mapped to a MIME type that is registered as font, false otherwise * @since Sitevision 2022.10.1 */ isFontType(aFileExtensionExpression: String | string): boolean; /** * Checks if a specified file extension is an audio type (according to its mapped MIME type). * *

* An audio type has a MIME that starts with "audio/". *

* @param aFileExtensionExpression a file extension (e.g wav) or an expression that ends with a period and a file extension (e.g myresource.wav or http://www.xyz.com/files/myresource.wav). Case insensitive. * @return true if aFileExtensionExpression is mapped to a audio/* MIME type, false otherwise * @since Sitevision 2024.04.1 */ isAudioType(aFileExtensionExpression: String | string): boolean; /** * Checks if a specified file extension is a JSON type (according to its mapped MIME type). * @param aFileExtensionExpression a file extension (e.g "json") or an expression that ends with a period and a file extension (e.g "myfile.json" or "https://www.xyz.com/files/myfile.json"). Case insensitive. * @return true if aFileExtensionExpression is mapped to a MIME type that depicts the JSON format, false otherwise * @see #isJsonMime(String) * @since Sitevision 2025.01.2 */ isJsonType(aFileExtensionExpression: String | string): boolean; /** * Checks if a specified MIME type depicts the JSON format. * *

* The primary JSON format MIME is "application/json" and should always be handled as UTF-8 text. Other MIME:s that uses the JSON * format typically has a "+json" suffix (see RFC 6839) * or a "+json-seq" suffix (see RFC 8091). But there * are also some legacy/unofficial MIME:s that also depicts the JSON format (e.g. "text/json", "application/jsonrequest"). * Example of typical MIME types that depicts the JSON format: *

* * *

* A Content-Type header value for a JSON response is typically "application/json; charset=utf-8". * This method handles such values, only the leading MIME part will be checked (any semicolon suffix part will be completely ignored). *

* @param aMimeType a MIME value or Content-Type header value * @return true if aMimeType matches a MIME that depicts the JSON format, false otherwise * @since Sitevision 2025.01.2 */ isJsonMime(aMimeType: String | string): boolean; } declare namespace MimeTypeUtil {} declare var mimeTypeUtil: MimeTypeUtil; export default mimeTypeUtil;