public class MediaTypeFactory
extends java.lang.Object
MediaType
objects
from Resource
handles or filenames.
This implementation is based on the Java Activation Framework, sharing the MIME type definitions with Spring's JavaMail support. However, JAF is an implementation detail and not leaking out.
Modifier and Type | Field and Description |
---|---|
private static javax.activation.FileTypeMap |
fileTypeMap |
Constructor and Description |
---|
MediaTypeFactory() |
Modifier and Type | Method and Description |
---|---|
static MediaType |
getMediaType(Resource resource)
Determine a media type for the given resource, if possible.
|
static MediaType |
getMediaType(java.lang.String filename)
Determine a media type for the given file name, if possible.
|
private static javax.activation.FileTypeMap |
loadFileTypeMapFromContextSupportModule() |
private static javax.activation.FileTypeMap loadFileTypeMapFromContextSupportModule()
public static MediaType getMediaType(Resource resource)
resource
- the resource to introspectnull
if none foundpublic static MediaType getMediaType(java.lang.String filename)
filename
- the file name plus extensionnull
if none found