net.rim.device.api.io
Class MIMETypeAssociations
java.lang.Object
net.rim.device.api.io.MIMETypeAssociations
public final class MIMETypeAssociations
- extends Object
This class provides an association between file extensions, MIME types and media types.
Authors are allowed to associate with a media type with an extension and query what type is associated
with a filename.
Sample code
String contentType =
MIMETypeAssociations.getMIMEType(fileName);
// Normalize and strip off parameters.
String normalizedContentType =
MIMETypeAssociations.getNormalizedType(contentType);
// Method to check if your application supports a particular MIME type.
public boolean supported(String mimeType)
{
return (mimeType != null
&& (MIMETypeAssociations.getMediaTypeFromMIMEType(
mimeType ) == MIMETypeAssociations.MEDIA_ parameter));
}
// Register the default extension for the MMS MIME type.
MIMETypeAssociations.registerType("mms",
"application/vnd.wap.mms-message",
MIMETypeAssociations.MEDIA_TYPE_UNKNOWN);
- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 4.2.0
MEDIA_TYPE_UNKNOWN
public static final int MEDIA_TYPE_UNKNOWN
- Media Type Unknown.
- See Also:
- Constant Field Values
- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 4.2.0
MEDIA_TYPE_IMAGE
public static final int MEDIA_TYPE_IMAGE
- Media Type Image.
- See Also:
- Constant Field Values
- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 4.2.0
MEDIA_TYPE_AUDIO
public static final int MEDIA_TYPE_AUDIO
- Media Type Audio.
- See Also:
- Constant Field Values
- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 4.2.0
MEDIA_TYPE_VIDEO
public static final int MEDIA_TYPE_VIDEO
- Media Type Video.
- See Also:
- Constant Field Values
- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 4.2.0
MEDIA_TYPE_TEXT
public static final int MEDIA_TYPE_TEXT
- Media Type Text.
- See Also:
- Constant Field Values
- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 4.2.0
MEDIA_TYPE_ARCHIVE
public static final int MEDIA_TYPE_ARCHIVE
- Media Type Archive.
- See Also:
- Constant Field Values
- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 4.2.0
MEDIA_TYPE_APPLICATION
public static final int MEDIA_TYPE_APPLICATION
- Media Type Application.
- See Also:
- Constant Field Values
- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 4.2.0
MEDIA_TYPE_PLAY_LIST
public static final int MEDIA_TYPE_PLAY_LIST
- Media Type Audio play list.
- See Also:
- Constant Field Values
- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 4.3.0
registerMIMETypeMapping
public static void registerMIMETypeMapping(String typeFrom,
String typeTo)
- Register a MIME type mapping, associating one MIME type to another MIME type.
- Parameters:
typeFrom
- The MIME type that the mapping is queried from.typeTo
- The MIME type that should be returned as a result of the mapping.
- Throws:
NullPointerException
- if typeFrom
or typeTo
is null- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 4.2.0
getMIMEType
public static String getMIMEType(String filename)
- Return the MIME type associated with a filename.
- Parameters:
filename
- The filename to query on.
- Returns:
- The associated MIME type (eg. "image/gif"), or null if the
type could not be determined from the filename; the input is an invalid MIME type, or the input is null.
- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 4.2.0
getMediaType
public static int getMediaType(String filename)
- Return the media type associated with a filename. If the media
type cannot be determined from the filename, this method returns
MEDIA_TYPE_UNKNOWN.
- Parameters:
filename
- The filename to query on.
- Returns:
- The associated media type (eg. MEDIA_TYPE_IMAGE) or MEDIA_TYPE_UNKNOWN if filename is null.
- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 4.2.0
getMediaTypeFromMIMEType
public static int getMediaTypeFromMIMEType(String mimeType)
- Return the media type associated with the MIME type. If the MIME type
is unknown or null, this method returns MEDIA_TYPE_UNKNOWN.
- Parameters:
mimeType
- The MIME type to query on.
- Returns:
- The media type that the MIME type is associated with.
- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 4.2.0
getExtensionFromMIMEType
public static String getExtensionFromMIMEType(String mimeType)
- Return the file extension associated with the MIME type.
- Parameters:
mimeType
- The MIME type to query on.
- Returns:
- The file extension that the MIME type is associated with,
or null if the MIME type is unknown or null.
- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 4.2.0
registerType
public static void registerType(String extension,
String mimeType,
int mediaType)
- Register a media and MIME type associated with an extension.
Note that this method does not override previously registered types or extensions.
If the extension is already registered, this method does nothing.
- Parameters:
extension
- The file extension to associate with.mimeType
- The MIME type the extension is associated with.mediaType
- The media type the extension is associated with; this can be MEDIA_TYPE_UNKNOWN or a private constant, but it should typically be one of MEDIA_TYPE_APPLICATION, MEDIA_TYPE_AUDIO, etc.
- Throws:
NullPointerException
- if mimeType
or extension
is null- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 4.2.0
getNormalizedType
public static String getNormalizedType(String mimeType)
- Return a normalized MIME type for the provided type.
The normalized type is the first mime type that was registered for a type, for example,
image/jpeg might return image/jpg for its normalized type.
This method removes parameters on the content type and maps MIME type aliases to the
preferred MIME type. For example, the normalized MIME type for
"audio/mp3" (non-standard) is "audio/mpeg" (as defined in RFC 3003 and
registered with the IANA).
If the MIME type is unknown, the type is returned with any parameters
removed. For example, the normalized type for
"text/x-unknown-type; charset=utf-8" is "text/x-unknown-type".
- Parameters:
mimeType
- The MIME type to be normalized (may be null, in which
case this method returns null).
- Returns:
- The normalized MIME type.
- See Also:
- MIME types registered with the IANA
- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 4.2.0
Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.