Package org.exoplatform.commons.utils
Class MimeTypeResolver
- java.lang.Object
-
- org.exoplatform.commons.utils.MimeTypeResolver
-
public class MimeTypeResolver extends Object
-
-
Constructor Summary
Constructors Constructor Description MimeTypeResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetDefaultMimeType()Returns default MIMEType.StringgetExtension(String mimeType)Get file extension corresponds to MIMEType.StringgetMimeType(String filename)Get MIMEType which corresponds to file extension.StringgetMimeType(String fileName, InputStream is)Get MIMEType which corresponds to file content.protected voidprocessLine(String aLine)Load MIMEType and corresponding extension.voidsetDefaultMimeType(String defaultMimeType)Set default MIMEType.
-
-
-
Field Detail
-
LOG
protected static final Log LOG
-
-
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-
-
-