Class DefaultMediaTypePredictor
java.lang.Object
org.glassfish.jersey.media.multipart.file.DefaultMediaTypePredictor
- All Implemented Interfaces:
MediaTypePredictor
Default implementation of
MediaTypePredictor
that uses
DefaultMediaTypePredictor.CommonMediaTypes
.- Author:
- Imran M Yousuf (imran at smartitengineering.com), Paul Sandoz, Michal Gajdos
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
This enum represents file extension and MIME types of commonly used file. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DefaultMediaTypePredictor
Gets the singleton instance of this class.getMediaTypeFromFile
(File file) Get the media type from a file name.getMediaTypeFromFileName
(String fileName) Get the media type from a file name.
-
Constructor Details
-
DefaultMediaTypePredictor
public DefaultMediaTypePredictor()
-
-
Method Details
-
getMediaTypeFromFile
Description copied from interface:MediaTypePredictor
Get the media type from a file name.- Specified by:
getMediaTypeFromFile
in interfaceMediaTypePredictor
- Parameters:
file
- the file from which to get theMediaType
.- Returns:
- the
MediaType
for the give file;null
- if file is null; "application/octet-stream" if extension not recognized. - See Also:
-
getMediaTypeFromFileName
Description copied from interface:MediaTypePredictor
Get the media type from a file name. If the file name extension is not recognised it will returnMediaType
for "*\/*", it will also return the same if the file isnull
.- Specified by:
getMediaTypeFromFileName
in interfaceMediaTypePredictor
- Parameters:
fileName
- the file name from which to get theMediaType
.- Returns:
- the
MediaType
for the give file;null
- if file is null; "application/octet-stream" if extension not recognized.
-
getInstance
Gets the singleton instance of this class.- Returns:
- the singleton instance.
-