eXo Kernel :: Commons Utils 2.4.10-UXP01

org.exoplatform.commons.utils
Class MimeTypeResolver

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

public class MimeTypeResolver
extends Object


Field Summary
protected static Log LOG
           
 
Constructor Summary
MimeTypeResolver()
           
 
Method Summary
 String getDefaultMimeType()
          Returns default MIMEType.
 String getExtension(String mimeType)
          Get file extension corresponds to MIMEType.
 String getMimeType(String filename)
          Get MIMEType which corresponds to file extension.
 String getMimeType(String fileName, InputStream is)
          Get MIMEType which corresponds to file content.
protected  void processLine(String aLine)
          Load MIMEType and corresponding extension.
 void setDefaultMimeType(String defaultMimeType)
          Set default MIMEType.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final Log LOG
Constructor Detail

MimeTypeResolver

public MimeTypeResolver()
Method Detail

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 -

eXo Kernel :: Commons Utils 2.4.10-UXP01

Copyright © 2014 eXo Platform SAS. All Rights Reserved.