Package com.twelvemonkeys.net
Class MIMEUtil
java.lang.Object
com.twelvemonkeys.net.MIMEUtil
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 $
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Removes any charset or extra info from the mime-type string (anything after a semicolon,;
, inclusive).static String
getExtension
(String pMIME) Returns the default file extension for the given MIME type.getExtensionForWildcard
(String pMIME) Returns an unmodifiabaleMap
view of the MIME to extension mapping, to use as the default mapping in client applications.getExtensions
(String pMIME) Returns all file extension for the given MIME type.static String
getMIMEType
(String pFileExt) Returns the default MIME type for the given file extension.Returns an unmodifiabaleMap
view of the extension to MIME mapping, to use as the default mapping in client applications.getMIMETypes
(String pFileExt) Returns all MIME types for the given file extension.(package private) static boolean
Tests wehter the type is a subtype of the type family.static void
For debugging.
-
Field Details
-
sExtToMIME
-
sUnmodifiableExtToMIME
-
sMIMEToExt
-
sUnmodifiableMIMEToExt
-
-
Constructor Details
-
MIMEUtil
private MIMEUtil()
-
-
Method Details
-
getMIMEType
Returns the default MIME type for the given file extension.- Parameters:
pFileExt
- the file extension- Returns:
- a
String
containing the MIME type, ornull
if there are no known MIME types for the given file extension.
-
getMIMETypes
Returns all MIME types for the given file extension.- Parameters:
pFileExt
- the file extension- Returns:
- a
List
ofString
s containing the MIME types, or an empty list, if there are no known MIME types for the given file extension.
-
getMIMETypeMappings
Returns an unmodifiabaleMap
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
Returns the default file extension for the given MIME type. Specifying a wildcard type will returnnull
.- Parameters:
pMIME
- the MIME type- Returns:
- a
String
containing the file extension, ornull
if there are no known file extensions for the given MIME type.
-
getExtensions
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
ofString
s containing the MIME types, or an empty list, if there are no known file extensions for the given MIME type.
-
getExtensionForWildcard
-
getExtensionMappings
Returns an unmodifiabaleMap
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.
-
includes
Tests wehter the type is a subtype of the type family.- Parameters:
pTypeFamily
- the MIME type family (image/*, */*
, etc)pType
- the MIME type- Returns:
true
ifpType
is a subtype ofpTypeFamily
, otherwisefalse
-
bareMIME
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
-
maskNull
-
main
For debugging. Prints all known MIME types and file extensions.- Parameters:
pArgs
- command line arguments
-