org.glassfish.jersey.media.multipart.file
Class DefaultMediaTypePredictor

java.lang.Object
  extended by org.glassfish.jersey.media.multipart.file.DefaultMediaTypePredictor
All Implemented Interfaces:
MediaTypePredictor

public class DefaultMediaTypePredictor
extends Object
implements MediaTypePredictor

Default implementation of MediaTypePredictor that uses DefaultMediaTypePredictor.CommonMediaTypes.

Author:
Imran M Yousuf (imran at smartitengineering.com), Paul Sandoz (paul.sandoz at oracle.com), Michal Gajdos (michal.gajdos at oracle.com)

Nested Class Summary
static class DefaultMediaTypePredictor.CommonMediaTypes
          This enum represents file extension and MIME types of commonly used file.
 
Constructor Summary
DefaultMediaTypePredictor()
           
 
Method Summary
static DefaultMediaTypePredictor getInstance()
          Gets the singleton instance of this class.
 javax.ws.rs.core.MediaType getMediaTypeFromFile(File file)
          Get the media type from a file name.
 javax.ws.rs.core.MediaType getMediaTypeFromFileName(String fileName)
          Get the media type from a file name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMediaTypePredictor

public DefaultMediaTypePredictor()
Method Detail

getMediaTypeFromFile

public javax.ws.rs.core.MediaType getMediaTypeFromFile(File file)
Description copied from interface: MediaTypePredictor
Get the media type from a file name.

Specified by:
getMediaTypeFromFile in interface MediaTypePredictor
Parameters:
file - the file from which to get the MediaType.
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(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 return MediaType for "*\/*", it will also return the same if the file is null.

Specified by:
getMediaTypeFromFileName in interface MediaTypePredictor
Parameters:
fileName - the file name from which to get the MediaType.
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.


Copyright © 2007-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.