Package org.exoplatform.commons.utils
Class MimeTypeResolver
java.lang.Object
org.exoplatform.commons.utils.MimeTypeResolver
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns default MIMEType.getExtension(String mimeType) Get file extension corresponds to MIMEType.getMimeType(String filename) Get MIMEType which corresponds to file extension.getMimeType(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 Details
-
LOG
-
-
Constructor Details
-
MimeTypeResolver
public MimeTypeResolver()
-
-
Method Details
-
getDefaultMimeType
Returns default MIMEType.- Returns:
- String
-
setDefaultMimeType
Set default MIMEType.- Parameters:
defaultMimeType- String, default MIMEType
-
getMimeType
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
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
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
Load MIMEType and corresponding extension.- Parameters:
aLine-
-