Copyright© 2008-2022 Sitevision AB, all rights reserved.
@Requireable(value="MimeTypeUtil") public interface MimeTypeUtil extends VelocityAccess.MimeTypeUtilConstants
An instance of the Sitevision class implementing this interface can be obtained via Utils.getMimeTypeUtil()
.
See Utils
for how to obtain an instance of the Utils
interface.
Modifier and Type | Field and Description |
---|---|
static String |
GENERIC_MIME_TYPE
The generic
application/octet-stream MIME type. |
Modifier and Type | Method and Description |
---|---|
String |
getExtension(String aMimeType)
Returns the file extension for a specified MIME type.
|
String |
getExtension(String aMimeType,
String aFallbackExtension)
Returns the file extension (or a fallback extension) for a specified MIME type.
|
String |
getMimeType(String aFileExtensionExpression)
Returns the MIME type appropriate for a specified file extension.
|
String |
getMimeType(String aFileExtensionExpression,
String aFallbackMimeType)
Returns the MIME type (or a fallback MIME type) appropriate for a specified file extension.
|
boolean |
isCompressedType(String aFileExtensionExpression)
Checks if a specified file extension is a compressed/archive type (according to its mapped MIME type).
|
boolean |
isFontType(String aFileExtensionExpression)
Checks if a specified file extension is a font type (according to its mapped MIME type).
|
boolean |
isImageType(String aFileExtensionExpression)
Checks if a specified file extension is an image type (according to its mapped MIME type).
|
boolean |
isMSExcelType(String aFileExtensionExpression)
Checks if a specified file extension is a MS Excel type (according to its mapped MIME type).
|
boolean |
isMSOfficeType(String aFileExtensionExpression)
Checks if a specified file extension is a MS Office type (according to its mapped MIME type).
|
boolean |
isMSPowerpointType(String aFileExtensionExpression)
Checks if a specified file extension is a MS Powerpoint type (according to its mapped MIME type).
|
boolean |
isMSWordType(String aFileExtensionExpression)
Checks if a specified file extension is a MS Word type (according to its mapped MIME type).
|
boolean |
isTextType(String aFileExtensionExpression)
Checks if a specified file extension is a text type (according to its mapped MIME type).
|
boolean |
isVideoType(String aFileExtensionExpression)
Checks if a specified file extension is a video type (according to its mapped MIME type).
|
boolean |
isXmlType(String aFileExtensionExpression)
Checks if a specified file extension is a text type (according to its mapped MIME type).
|
getGENERIC_MIME_TYPE
static final String GENERIC_MIME_TYPE
application/octet-stream
MIME type.
Would typically be appropriate to use as value for the fallback MIME type when using the
getMimeType(String, String)
whenever you require an acceptable, non-null MIME type to be returned.
String mime = aMimeTypeUtil.getMimeType(anExtension, MimeTypeUtil.GENERIC_MIME_TYPE);
String getMimeType(String aFileExtensionExpression)
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.aFileExtensionExpression
, or null
if
extension is unknowngetMimeType(String, String)
String getMimeType(String aFileExtensionExpression, String aFallbackMimeType)
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.aFallbackMimeType
- the fallback MIME type to return if no MIME type can be found for aFileExtensionExpression
aFileExtensionExpression
, or aFallbackMimeType
if
extension is unknownString getExtension(String aMimeType)
aMimeType
- a MIME type. Case insensitive.aMimeType
, or null
if
aMimeType
is unknown or has no single well-known extension (e.g. application/octet-stream or text/plain)getExtension(String, String)
String getExtension(String aMimeType, String aFallbackExtension)
aMimeType
- a MIME type. Case insensitive.aFallbackExtension
- the fallback extension to return if no extension can be found for aMimeType
aMimeType
, or aFallbackExtension
if
aMimeType
is unknown or has no single well-known extension (e.g. application/octet-stream or text/plain)boolean isImageType(String aFileExtensionExpression)
An image type has a MIME that starts with image/
.
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.aFileExtensionExpression
is mapped to a image/*
MIME type, false otherwiseboolean isTextType(String aFileExtensionExpression)
A text type has a MIME that starts with "text/
".
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.aFileExtensionExpression
is mapped to a text/*
MIME type, false otherwiseboolean isXmlType(String aFileExtensionExpression)
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).
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.aFileExtensionExpression
is mapped to a application/*xml
MIME type, false otherwiseboolean isVideoType(String aFileExtensionExpression)
A video type has a MIME that starts with "video/
".
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.aFileExtensionExpression
is mapped to a video/*
MIME type, false otherwiseboolean isCompressedType(String aFileExtensionExpression)
Example of compressed MIME types:
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.aFileExtensionExpression
is mapped to a MIME type that is registered as compressed, false otherwiseboolean isMSWordType(String aFileExtensionExpression)
Example of typical MS Word MIME types:
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.aFileExtensionExpression
is mapped to a MS Word MIME type, false otherwiseboolean isMSExcelType(String aFileExtensionExpression)
Example of typical MS Excel MIME types:
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.aFileExtensionExpression
is mapped to a MS Excel MIME type, false otherwiseboolean isMSPowerpointType(String aFileExtensionExpression)
Example of typical MS Powerpoint MIME types:
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.aFileExtensionExpression
is mapped to a MS Powerpoint MIME type, false otherwiseboolean isMSOfficeType(String aFileExtensionExpression)
This is a convenience method that checks if aFileExtensionExpression
is mapped to a MS Word/Excel/Powerpoint MIME type.
(i.e. a combination of isMSWordType(String)
, isMSExcelType(String)
and isMSPowerpointType(String)
)
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.aFileExtensionExpression
is mapped to a MS Word/Excel/Powerpoint MIME type, false otherwiseboolean isFontType(String aFileExtensionExpression)
Example of typical font MIME types:
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.Sitevision - Portal and Content Management Made Easy
Sitevision is an advanced Java enterprise portal product and a portlet container (JSR 286) that implements Java Content Repository (JSR 283).
Copyright© 2008-2022 Sitevision AB, all rights reserved.