Class DefaultMediaTypePredictor
- java.lang.Object
-
- org.glassfish.jersey.media.multipart.file.DefaultMediaTypePredictor
-
- All Implemented Interfaces:
MediaTypePredictor
public class DefaultMediaTypePredictor extends java.lang.Object implements MediaTypePredictor
Default implementation ofMediaTypePredictor
that usesDefaultMediaTypePredictor.CommonMediaTypes
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultMediaTypePredictor.CommonMediaTypes
This enum represents file extension and MIME types of commonly used file.
-
Field Summary
Fields Modifier and Type Field Description private static DefaultMediaTypePredictor
MEDIA_TYPE_PREDICTOR
-
Constructor Summary
Constructors Constructor Description DefaultMediaTypePredictor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DefaultMediaTypePredictor
getInstance()
Gets the singleton instance of this class.javax.ws.rs.core.MediaType
getMediaTypeFromFile(java.io.File file)
Get the media type from a file name.javax.ws.rs.core.MediaType
getMediaTypeFromFileName(java.lang.String fileName)
Get the media type from a file name.
-
-
-
Field Detail
-
MEDIA_TYPE_PREDICTOR
private static final DefaultMediaTypePredictor MEDIA_TYPE_PREDICTOR
-
-
Method Detail
-
getMediaTypeFromFile
public javax.ws.rs.core.MediaType getMediaTypeFromFile(java.io.File file)
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:
DefaultMediaTypePredictor.CommonMediaTypes.getMediaTypeFromFileName(java.lang.String)
-
getMediaTypeFromFileName
public javax.ws.rs.core.MediaType getMediaTypeFromFileName(java.lang.String fileName)
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
public static DefaultMediaTypePredictor getInstance()
Gets the singleton instance of this class.- Returns:
- the singleton instance.
-
-