org.gcube.portlets.user.homelibrary.util
Class MimeTypeUtil

java.lang.Object
  extended by org.gcube.portlets.user.homelibrary.util.MimeTypeUtil

public class MimeTypeUtil
extends Object

Author:
Federico De Faveri defaveri@isti.cnr.it

Field Summary
static String BINARY_MIMETYPE
           
protected static Map<String,String> extension_mimetype_map
           
protected static org.apache.log4j.Logger logger
           
protected static Map<String,String> mimetype_extension_map
           
static String[] ZIP_MIMETYPES
           
 
Constructor Summary
MimeTypeUtil()
           
 
Method Summary
static String getExtension(String mimeType)
           
static String getMimeType(File file)
           
static String getMimeType(InputStream file)
           
static String getMimeType(String extension)
           
static String getNameWithExtension(String name, String mimeType)
           
static boolean isZipContentType(String contentType)
          Check if the content type is a zip type.
protected static void loadExtensions(InputStream is)
           
protected static void loadMimeTypes(InputStream is)
           
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger

BINARY_MIMETYPE

public static final String BINARY_MIMETYPE
See Also:
Constant Field Values

ZIP_MIMETYPES

public static final String[] ZIP_MIMETYPES

mimetype_extension_map

protected static final Map<String,String> mimetype_extension_map

extension_mimetype_map

protected static final Map<String,String> extension_mimetype_map
Constructor Detail

MimeTypeUtil

public MimeTypeUtil()
Method Detail

loadExtensions

protected static void loadExtensions(InputStream is)
                              throws IOException
Throws:
IOException

loadMimeTypes

protected static void loadMimeTypes(InputStream is)
                             throws IOException
Throws:
IOException

getExtension

public static String getExtension(String mimeType)
Parameters:
mimeType - the mime type.
Returns:
the related extension.

getMimeType

public static String getMimeType(String extension)
Parameters:
extension - the extension.
Returns:
the related mime type.

getMimeType

public static String getMimeType(File file)
Parameters:
file - the file to check.
Returns:
the mime type.

getMimeType

public static String getMimeType(InputStream file)
Parameters:
file - the file to check
Returns:
the mime type.

main

public static void main(String[] args)
                 throws IOException
Parameters:
args - arguments.
Throws:
IOException - if an error occurs.

getNameWithExtension

public static String getNameWithExtension(String name,
                                          String mimeType)
Parameters:
name - the file name.
mimeType - the mime type.
Returns:
the right name.

isZipContentType

public static boolean isZipContentType(String contentType)
Check if the content type is a zip type.

Parameters:
contentType - the content type to check.
Returns:
true if is a zip file, false otherwise.


Copyright © 2013. All Rights Reserved.