public class MimeTypeMapperImpl extends Object implements MimeTypeMapper
MimeTypeMapper
interface that searches through all of the
registered MimeTypeResolver
s 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 MimeTypeResolver
s and returns.Modifier and Type | Field and Description |
---|---|
protected MimeTypeResolver |
mimeTypeResolver |
protected List<MimeTypeResolver> |
mimeTypeResolvers
The
List of MimeTypeResolver s 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
MimeTypeResolver s. |
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 MimeTypeResolver
s configured for this mapper and will be searched
on mime type/file extension mapping requests.protected MimeTypeResolver mimeTypeResolver
public MimeTypeMapperImpl(List<MimeTypeResolver> mimeTypeResolvers)
MimeTypeResolver
s.mimeTypeResolvers
- the List
of MimeTypeResolver
spublic String getFileExtensionForMimeType(String mimeType) throws MimeTypeResolutionException
MimeTypeMapper
getFileExtensionForMimeType
in interface MimeTypeMapper
mimeType
- the mime typeMimeTypeResolutionException
public String getMimeTypeForFileExtension(String fileExtension) throws MimeTypeResolutionException
MimeTypeMapper
getMimeTypeForFileExtension
in interface MimeTypeMapper
fileExtension
- the file extension to look up the mime type forMimeTypeResolutionException
public String guessMimeType(InputStream is, String fileExtension) throws MimeTypeResolutionException
MimeTypeMapper
guessMimeType
in interface MimeTypeMapper
is
- 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.