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 enumThis enum represents file extension and MIME types of commonly used file. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DefaultMediaTypePredictorGets 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:MediaTypePredictorGet the media type from a file name.- Specified by:
getMediaTypeFromFilein interfaceMediaTypePredictor- Parameters:
file- the file from which to get theMediaType.- Returns:
- the
MediaTypefor the give file;null- if file is null; "application/octet-stream" if extension not recognized. - See Also:
-
getMediaTypeFromFileName
Description copied from interface:MediaTypePredictorGet the media type from a file name. If the file name extension is not recognised it will returnMediaTypefor "*\/*", it will also return the same if the file isnull.- Specified by:
getMediaTypeFromFileNamein interfaceMediaTypePredictor- Parameters:
fileName- the file name from which to get theMediaType.- Returns:
- the
MediaTypefor 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.
-