Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD

## com.sun.jersey.multipart.file
Enum DefaultMediaTypePredictor.CommonMediaTypes

    java.lang.Object
      java.lang.Enum<DefaultMediaTypePredictor.CommonMediaTypes>
          com.sun.jersey.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. Curently 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

Enum Constant Summary
`AVI`
`BMP`
`GIF`
`GZ`
`HTM`
`HTML`
`JPG`
`MP3`
`MPEG`
`PDF`
`PNG`
`RAR`
`TAR`
`TXT`
`WAV`
`XML`
`ZIP`

Method Summary
`java.lang.String` | `getExtension()` Get the file extension.
`MediaType` | `getMediaType()` Get the media type.
`static MediaType` | `getMediaTypeFromFile(java.io.File file)` A utility method for predicting media type from a file name.
`static 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.

Methods inherited from class java.lang.Enum
`clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

Methods inherited from class java.lang.Object
`getClass, notify, notifyAll, wait, wait, wait`

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 name
    `java.lang.NullPointerException` - if the argument is null

### getExtension

    public java.lang.String getExtension()

  Get the file extension.

  Returns:
    the file extension.

### getMediaType

    public MediaType getMediaType()

  Get the media type.

  Returns:
    the media type.

### getMediaTypeFromFile

    public static 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 the `MediaType`
  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 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 return `MediaType` for "*\/*", it will also return the same if the file is `null`. Currently supported file extensions can be found at `DefaultMediaTypePredictor.CommonMediaTypes`.

  Parameters:
    `fileName` - The file name from which to predict the `MediaType`
  Returns:
    The `MediaType` for the give file; `null` - if file is null; "application/octet-stream" if extension not recognized.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD

Copyright © 2011 Oracle Corporation. All Rights Reserved.