Class MimeTypeResolver

java.lang.Object
org.exoplatform.commons.utils.MimeTypeResolver

public class MimeTypeResolver extends Object
  • Field Details

    • LOG

      protected static final Log LOG
  • Constructor Details

    • MimeTypeResolver

      public MimeTypeResolver()
  • Method Details

    • getDefaultMimeType

      public String getDefaultMimeType()
      Returns default MIMEType.
      Returns:
      String
    • setDefaultMimeType

      public void setDefaultMimeType(String defaultMimeType)
      Set default MIMEType.
      Parameters:
      defaultMimeType - String, default MIMEType
    • getMimeType

      public String getMimeType(String filename)
      Get MIMEType which corresponds to file extension. If file extension is unknown the default MIMEType will be returned. If there are more than one MIMETypes for specific extension the first occurred in the list will be returned.
      Parameters:
      filename -
      Returns:
      String MIMEType
    • getMimeType

      public String getMimeType(String fileName, InputStream is)
      Get MIMEType which corresponds to file content. If file content does not allow to determine MIMEtype, the default MIMEType will be returned.
      Parameters:
      fileName -
      is -
      Returns:
      String MIMEType
    • getExtension

      public String getExtension(String mimeType)
      Get file extension corresponds to MIMEType. If MIMEType is empty or equals default MIMEType empty string will be returned. If there is no file extension for specific MIMEType the empty string will be returned also. In case when there are more than one extension for specific MIMEType the first occurred extension in the list will be returned if MIMEType ends with this extension otherwise just first occurred.
      Parameters:
      mimeType - MIMEType
      Returns:
      file extension
    • processLine

      protected void processLine(String aLine)
      Load MIMEType and corresponding extension.
      Parameters:
      aLine -