Enum DefaultMediaTypePredictor.CommonMediaTypes
java.lang.Object
java.lang.Enum<DefaultMediaTypePredictor.CommonMediaTypes>
org.glassfish.jersey.media.multipart.file.DefaultMediaTypePredictor.CommonMediaTypes
- All Implemented Interfaces:
Serializable,Comparable<DefaultMediaTypePredictor.CommonMediaTypes>,java.lang.constant.Constable
- Enclosing class:
DefaultMediaTypePredictor
public static enum DefaultMediaTypePredictor.CommonMediaTypes
extends Enum<DefaultMediaTypePredictor.CommonMediaTypes>
This enum represents file extension and MIME types of commonly used file. It
is to be noted that all file extension and MIME types are specified in lower
case, when checking the extension this should be kept in mind.
Currently supported file extension and MIME Types are -
- ".xml" - application/xml
- ".txt" - text/plain
- ".pdf" - application/pdf
- ".htm" - text/html
- ".html" - text/html
- ".jpg" - image/jpeg
- ".png" - image/png
- ".gif" - image/gif
- ".bmp" - image/bmp
- ".tar" - application/x-tar
- ".zip" - application/zip
- ".gz" - application/x-gzip
- ".rar" - application/x-rar
- ".mp3" - audio/mpeg
- ".wav" - audio/x-wave
- ".avi" - video/x-msvideo
- ".mpeg" - video/mpeg
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateCommonMediaTypes(String extension, javax.ws.rs.core.MediaType mediaType) -
Method Summary
Modifier and TypeMethodDescriptionGets the file extension.javax.ws.rs.core.MediaTypeGets the media type.static javax.ws.rs.core.MediaTypegetMediaTypeFromFile(File file) A utility method for predicting media type from a file name.static javax.ws.rs.core.MediaTypegetMediaTypeFromFileName(String fileName) A utility method for predicting media type from a file name.Returns the enum constant of this type with the specified name.values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
XML
-
TXT
-
HTM
-
HTML
-
PDF
-
JPG
-
PNG
-
GIF
-
BMP
-
TAR
-
ZIP
-
GZ
-
RAR
-
MP3
-
WAV
-
AVI
-
MPEG
-
-
Field Details
-
extension
-
mediaType
private final javax.ws.rs.core.MediaType mediaType
-
-
Constructor Details
-
CommonMediaTypes
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
getExtension
Gets the file extension.- Returns:
- the file extension.
-
getMediaType
public javax.ws.rs.core.MediaType getMediaType()Gets the media type.- Returns:
- the media type.
-
getMediaTypeFromFile
A utility method for predicting media type from a file name.- Parameters:
file- the file from which to predict theMediaType- Returns:
- the
MediaTypefor the give file;null- if file is null; "application/octet-stream" if extension not recognized. - See Also:
-
getMediaTypeFromFileName
A utility method for predicting 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. Currently supported file extensions can be found atDefaultMediaTypePredictor.CommonMediaTypes.- Parameters:
fileName- the file name from which to predict theMediaType- Returns:
- the
MediaTypefor the give file;null- if file is null; "application/octet-stream" if extension not recognized.
-