Enum DefaultMediaTypePredictor.CommonMediaTypes
- java.lang.Object
-
- java.lang.Enum<DefaultMediaTypePredictor.CommonMediaTypes>
-
- org.glassfish.jersey.media.multipart.file.DefaultMediaTypePredictor.CommonMediaTypes
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<DefaultMediaTypePredictor.CommonMediaTypes>
- Enclosing class:
- DefaultMediaTypePredictor
public static enum DefaultMediaTypePredictor.CommonMediaTypes extends java.lang.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
-
-
Constructor Summary
Constructors Modifier Constructor Description private
CommonMediaTypes(java.lang.String extension, javax.ws.rs.core.MediaType mediaType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getExtension()
Gets the file extension.javax.ws.rs.core.MediaType
getMediaType()
Gets the media type.static javax.ws.rs.core.MediaType
getMediaTypeFromFile(java.io.File file)
A utility method for predicting media type from a file name.static javax.ws.rs.core.MediaType
getMediaTypeFromFileName(java.lang.String fileName)
A utility method for predicting media type from a file name.static DefaultMediaTypePredictor.CommonMediaTypes
valueOf(java.lang.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
-
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(java.lang.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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
getExtension
public java.lang.String 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
public static javax.ws.rs.core.MediaType getMediaTypeFromFile(java.io.File file)
A utility method for predicting media type from a file name.- Parameters:
file
- the file from which to predict theMediaType
- Returns:
- the
MediaType
for the give file;null
- if file is null; "application/octet-stream" if extension not recognized. - See Also:
getMediaTypeFromFileName(java.lang.String)
-
getMediaTypeFromFileName
public static javax.ws.rs.core.MediaType getMediaTypeFromFileName(java.lang.String fileName)
A utility method for predicting 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
. Currently supported file extensions can be found atDefaultMediaTypePredictor.CommonMediaTypes
.- Parameters:
fileName
- the file name from which to predict theMediaType
- Returns:
- the
MediaType
for the give file;null
- if file is null; "application/octet-stream" if extension not recognized.
-
-