public class MimeTypeMapperImpl extends Object implements MimeTypeMapper
MimeTypeMapper interface that searches through all of the
registered MimeTypeResolvers to retieve file extension for a given mime type, and vice
versa. Once a file extension (or mime type) is resolved, this mapper stops searching through any
remaining MimeTypeResolvers and returns.| Modifier and Type | Field and Description |
|---|---|
protected MimeTypeResolver |
mimeTypeResolver |
protected List<MimeTypeResolver> |
mimeTypeResolvers
The
List of MimeTypeResolvers configured for this mapper and will be searched
on mime type/file extension mapping requests. |
| Constructor and Description |
|---|
MimeTypeMapperImpl(List<MimeTypeResolver> mimeTypeResolvers)
Constructs the MimeTypeMapper with a list of
MimeTypeResolvers. |
| Modifier and Type | Method and Description |
|---|---|
String |
getFileExtensionForMimeType(String mimeType)
Retrieves the file extension for the specified mime type, e.g., returns ".nitf" for a mime type
of "image/nitf".
|
String |
getMimeTypeForFileExtension(String fileExtension)
Retrieves the mime type for the specified file extension, e.g., returns "image/nitf" for a file
extension of "nitf".
|
String |
guessMimeType(InputStream is,
String fileExtension)
Attempts to guess the mime type for the specified file extension by introspecting the supplied
InputStream if necessary.
|
protected List<MimeTypeResolver> mimeTypeResolvers
List of MimeTypeResolvers configured for this mapper and will be searched
on mime type/file extension mapping requests.protected MimeTypeResolver mimeTypeResolver
public MimeTypeMapperImpl(List<MimeTypeResolver> mimeTypeResolvers)
MimeTypeResolvers.mimeTypeResolvers - the List of MimeTypeResolverspublic String getFileExtensionForMimeType(String mimeType) throws MimeTypeResolutionException
MimeTypeMappergetFileExtensionForMimeType in interface MimeTypeMappermimeType - the mime typeMimeTypeResolutionExceptionpublic String getMimeTypeForFileExtension(String fileExtension) throws MimeTypeResolutionException
MimeTypeMappergetMimeTypeForFileExtension in interface MimeTypeMapperfileExtension - the file extension to look up the mime type forMimeTypeResolutionExceptionpublic String guessMimeType(InputStream is, String fileExtension) throws MimeTypeResolutionException
MimeTypeMapperguessMimeType in interface MimeTypeMapperis - InputStream for the @File associated with the file extensionfileExtension - the file extension to look up the mime type forMimeTypeResolutionException - if any problems encountered during mime type mappingThis work is licensed under a Creative Commons Attribution 4.0 International License.