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>
- 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
- ".json - application/json
- ".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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetExtension()Gets the file extension.jakarta.ws.rs.core.MediaTypegetMediaType()Gets the media type.static jakarta.ws.rs.core.MediaTypegetMediaTypeFromFile(File file)A utility method for predicting media type from a file name.static jakarta.ws.rs.core.MediaTypegetMediaTypeFromFileName(String fileName)A utility method for predicting media type from a file name.static DefaultMediaTypePredictor.CommonMediaTypesvalueOf(String name)Returns the enum constant of this type with the specified name.static DefaultMediaTypePredictor.CommonMediaTypes[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
XML
public static final DefaultMediaTypePredictor.CommonMediaTypes XML
-
JSON
public static final DefaultMediaTypePredictor.CommonMediaTypes JSON
-
TXT
public static final DefaultMediaTypePredictor.CommonMediaTypes TXT
-
HTM
public static final DefaultMediaTypePredictor.CommonMediaTypes HTM
-
HTML
public static final DefaultMediaTypePredictor.CommonMediaTypes HTML
-
PDF
public static final DefaultMediaTypePredictor.CommonMediaTypes PDF
-
JPG
public static final DefaultMediaTypePredictor.CommonMediaTypes JPG
-
PNG
public static final DefaultMediaTypePredictor.CommonMediaTypes PNG
-
GIF
public static final DefaultMediaTypePredictor.CommonMediaTypes GIF
-
BMP
public static final DefaultMediaTypePredictor.CommonMediaTypes BMP
-
TAR
public static final DefaultMediaTypePredictor.CommonMediaTypes TAR
-
ZIP
public static final DefaultMediaTypePredictor.CommonMediaTypes ZIP
-
GZ
public static final DefaultMediaTypePredictor.CommonMediaTypes GZ
-
RAR
public static final DefaultMediaTypePredictor.CommonMediaTypes RAR
-
MP3
public static final DefaultMediaTypePredictor.CommonMediaTypes MP3
-
WAV
public static final DefaultMediaTypePredictor.CommonMediaTypes WAV
-
AVI
public static final DefaultMediaTypePredictor.CommonMediaTypes AVI
-
MPEG
public static final DefaultMediaTypePredictor.CommonMediaTypes MPEG
-
-
Method Detail
-
values
public static DefaultMediaTypePredictor.CommonMediaTypes[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (DefaultMediaTypePredictor.CommonMediaTypes c : DefaultMediaTypePredictor.CommonMediaTypes.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static DefaultMediaTypePredictor.CommonMediaTypes valueOf(String name)
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
public String getExtension()
Gets the file extension.- Returns:
- the file extension.
-
getMediaType
public jakarta.ws.rs.core.MediaType getMediaType()
Gets the media type.- Returns:
- the media type.
-
getMediaTypeFromFile
public static jakarta.ws.rs.core.MediaType getMediaTypeFromFile(File file)
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(java.lang.String)
-
getMediaTypeFromFileName
public static jakarta.ws.rs.core.MediaType getMediaTypeFromFileName(String fileName)
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.
-
-