Novell exteNd
Director 5.2 API

com.sssw.fw.util
Class EboMimeTypeHelper

java.lang.Object
 |
 +--com.sssw.fw.util.EboMimeTypeHelper

public class EboMimeTypeHelper
extends Object

Helper class that provides dynamic file/extension-to-mimetype mapping utility methods.


Field Summary
static String MT_APPLICATION_OCTET_STREAM
          Constant for the "application/octet-stream" MIME type.
static String MT_TEXT_PLAIN
          Constant for the "text/plain" MIME type.
 
Constructor Summary
EboMimeTypeHelper()
           
 
Method Summary
static String getExtensionByMimeType(String mimeType)
          Gets a file extension that may be used for the specified mimetype.
static String[] getExtensionsByMimeType(String mimeType)
          Gets the list of any extensions that may be used for the specified mimetype.
static String getMimeType(String fileName)
          Gets the mimetype for a given file name based on file extension mappings that have been specified in the Director FrameworkService subsystem's config.xml file.
static String getMimeTypeByExtension(String extension)
          Gets the mimetype for a given file name based on file extension mappings that have been specified in the Director FrameworkService subsystem's config.xml file.
static String getMimeTypeByFileName(String fileName)
          Gets the mimetype for a given file name based on file extension mappings that have been specified in the Director FrameworkService subsystem's config.xml file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MT_APPLICATION_OCTET_STREAM

public static final String MT_APPLICATION_OCTET_STREAM
Constant for the "application/octet-stream" MIME type.

MT_TEXT_PLAIN

public static final String MT_TEXT_PLAIN
Constant for the "text/plain" MIME type.
Constructor Detail

EboMimeTypeHelper

public EboMimeTypeHelper()
Method Detail

getMimeType

public static String getMimeType(String fileName)
Gets the mimetype for a given file name based on file extension mappings that have been specified in the Director FrameworkService subsystem's config.xml file. Returns null if no file extension is included in the passed file name or if the extension in the file name is not matched in the FrameworkService config.xml file.
Parameters:
fileName - file name for which you would like the mimetype
Returns:
the MIME type or null if no file extension is included in the passed file name or no match found in the config file

getMimeTypeByFileName

public static String getMimeTypeByFileName(String fileName)
Gets the mimetype for a given file name based on file extension mappings that have been specified in the Director FrameworkService subsystem's config.xml file. If no file extension is included in the passed file name, then a mimetype of "text/plain" is returned. If a file extension is included in the passed file name but not matched in the FrameworkService config.xml file, a mimetype of "application/octet-stream" is returned.
Parameters:
fileName - file name for which you would like the mimetype
Returns:
mimetype as a String

getMimeTypeByExtension

public static String getMimeTypeByExtension(String extension)
Gets the mimetype for a given file name based on file extension mappings that have been specified in the Director FrameworkService subsystem's config.xml file. If the passed file extension does not match any of the file extensions included in the FrameworkService config.xml file, a mimetype of "application/octet-stream" is returned.
Parameters:
extension - file extension for which you would like the mimetype
Returns:
mimetype as a String

getExtensionByMimeType

public static String getExtensionByMimeType(String mimeType)
Gets a file extension that may be used for the specified mimetype. Note that multiple file extensions may be allowed for a specific mimetype; this method returns one such extension. Use the getExtensionsByMimeType method to get the list of all the suitable file extensions.
Parameters:
mimeType - the mime type
Returns:
a file extension, or null if none found

getExtensionsByMimeType

public static String[] getExtensionsByMimeType(String mimeType)
Gets the list of any extensions that may be used for the specified mimetype. The list comes from the the Director FrameworkService subsystem's config.xml file.
Parameters:
mimeType - the mimetype
Returns:
the list of any matching extensions; empty if none found

Novell exteNd
Director 5.2 API