Package ddf.mime

Interface MimeTypeMapper


public interface MimeTypeMapper
Interface defining a mapper that accesses MimeTypeResolvers to retieve file extension for a given mime type, and vice versa.
Author:
Hugh Rodgers
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieves the file extension for the specified mime type, e.g., returns ".nitf" for a mime type of "image/nitf".
    Retrieves the mime type for the specified file extension, e.g., returns "image/nitf" for a file extension of "nitf".
    guessMimeType(InputStream is, String fileExtension)
    Attempts to guess the mime type for the specified file extension by introspecting the supplied InputStream if necessary.
  • Method Details

    • getFileExtensionForMimeType

      String getFileExtensionForMimeType(String contentType) throws MimeTypeResolutionException
      Retrieves the file extension for the specified mime type, e.g., returns ".nitf" for a mime type of "image/nitf".
      Parameters:
      contentType - the mime type
      Returns:
      the file extension mapped to the specified mime type
    • getMimeTypeForFileExtension

      String getMimeTypeForFileExtension(String fileExtension) throws MimeTypeResolutionException
      Retrieves the mime type for the specified file extension, e.g., returns "image/nitf" for a file extension of "nitf".
      Parameters:
      fileExtension - the file extension to look up the mime type for
      Returns:
      the mime type mapped to the specified file extension
    • guessMimeType

      String guessMimeType(InputStream is, String fileExtension) throws MimeTypeResolutionException
      Attempts to guess the mime type for the specified file extension by introspecting the supplied InputStream if necessary.
      Parameters:
      is - InputStream for the @File associated with the file extension
      fileExtension - the file extension to look up the mime type for
      Returns:
      the mime type mapped for the specified file extension; returns null if it cannot determine the mime type
      Throws:
      MimeTypeResolutionException - if any problems encountered during mime type mapping