com.twelvemonkeys.net
Class MIMEUtil

java.lang.Object
  extended by com.twelvemonkeys.net.MIMEUtil

public final class MIMEUtil
extends java.lang.Object

Contains mappings from file extension to mime-types and from mime-type to file-types.

Version:
$Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/net/MIMEUtil.java#5 $
Author:
Harald Kuhr
See Also:
MIME Media Types

Method Summary
static java.lang.String bareMIME(java.lang.String pMIME)
          Removes any charset or extra info from the mime-type string (anything after a semicolon, ;, inclusive).
static java.lang.String getExtension(java.lang.String pMIME)
          Returns the default file extension for the given MIME type.
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> getExtensionMappings()
          Returns an unmodifiabale Map view of the MIME to extension mapping, to use as the default mapping in client applications.
static java.util.List<java.lang.String> getExtensions(java.lang.String pMIME)
          Returns all file extension for the given MIME type.
static java.lang.String getMIMEType(java.lang.String pFileExt)
          Returns the default MIME type for the given file extension.
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> getMIMETypeMappings()
          Returns an unmodifiabale Map view of the extension to MIME mapping, to use as the default mapping in client applications.
static java.util.List<java.lang.String> getMIMETypes(java.lang.String pFileExt)
          Returns all MIME types for the given file extension.
static void main(java.lang.String[] pArgs)
          For debugging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getMIMEType

public static java.lang.String getMIMEType(java.lang.String pFileExt)
Returns the default MIME type for the given file extension.

Parameters:
pFileExt - the file extension
Returns:
a String containing the MIME type, or null if there are no known MIME types for the given file extension.

getMIMETypes

public static java.util.List<java.lang.String> getMIMETypes(java.lang.String pFileExt)
Returns all MIME types for the given file extension.

Parameters:
pFileExt - the file extension
Returns:
a List of Strings containing the MIME types, or an empty list, if there are no known MIME types for the given file extension.

getMIMETypeMappings

public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> getMIMETypeMappings()
Returns an unmodifiabale Map view of the extension to MIME mapping, to use as the default mapping in client applications.

Returns:
an unmodifiabale Map view of the extension to MIME mapping.

getExtension

public static java.lang.String getExtension(java.lang.String pMIME)
Returns the default file extension for the given MIME type. Specifying a wildcard type will return null.

Parameters:
pMIME - the MIME type
Returns:
a String containing the file extension, or null if there are no known file extensions for the given MIME type.

getExtensions

public static java.util.List<java.lang.String> getExtensions(java.lang.String pMIME)
Returns all file extension for the given MIME type. The default extension will be the first in the list. Note that no specific order is given for wildcard types (image/*, */* etc).

Parameters:
pMIME - the MIME type
Returns:
a List of Strings containing the MIME types, or an empty list, if there are no known file extensions for the given MIME type.

getExtensionMappings

public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> getExtensionMappings()
Returns an unmodifiabale Map view of the MIME to extension mapping, to use as the default mapping in client applications.

Returns:
an unmodifiabale Map view of the MIME to extension mapping.

bareMIME

public static java.lang.String bareMIME(java.lang.String pMIME)
Removes any charset or extra info from the mime-type string (anything after a semicolon, ;, inclusive).

Parameters:
pMIME - the mime-type string
Returns:
the bare mime-type

main

public static void main(java.lang.String[] pArgs)
For debugging. Prints all known MIME types and file extensions.

Parameters:
pArgs - command line arguments


Copyright © 2014. All Rights Reserved.