OOP Pop3Receiver Version 2.2

com.bentofw.util
Class MimeMapDic

java.lang.Object
  extended by com.bentofw.util.MimeMapDic

public class MimeMapDic
extends java.lang.Object

Resolve the mime-type from the file name.

Author:
Jun Inamori

Method Summary
static java.lang.String getFileExtension(java.lang.String file)
          Return the extension for the specified file name, such as png or txt.
 java.lang.String getFileExtension4Mime(java.lang.String mime)
          Return the file extension for the specified mime-type.
static MimeMapDic getInstance()
          Reads "WEB-INF/classes/mime.xml" and stores the mapping between the file extension and mime-type.
 java.lang.String getMimeType(java.lang.String file)
          Return the mime-type for the specified file name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static MimeMapDic getInstance()
                              throws NestedException,
                                     NoPropertyFileException
Reads "WEB-INF/classes/mime.xml" and stores the mapping between the file extension and mime-type.

The XML also defines the default mime-type, which will be returned in case that the corresponding mime-type is missing.

Returns:
MimeMapDic object
Throws:
NestedException
NoPropertyFileException
See Also:
getMimeType(String)

getMimeType

public java.lang.String getMimeType(java.lang.String file)
Return the mime-type for the specified file name.

This method extracts the file extension of the specified file name and queries its corresponding mime-type. In case of failure, the default mime-type will be returned.

If this method cannot extract the file extension, which means there is no '.' found in the file name, this method will return the default mime-type.

Parameters:
file - file name
Returns:
mime-type for the given file name

getFileExtension4Mime

public java.lang.String getFileExtension4Mime(java.lang.String mime)
Return the file extension for the specified mime-type.

This method queries the corresponding file extension for the specified mime-type. In case of failure, the empty string will be returned.

Parameters:
mime - mime-type
Returns:
file extesion for the mime-type
Since:
4.3

getFileExtension

public static java.lang.String getFileExtension(java.lang.String file)
Return the extension for the specified file name, such as png or txt.

This method extracts the file extension from the specified file name.

If this method cannot extract the file extension, which means there is no '.' found in the file name, this method will return the empty String.

Parameters:
file - file name
Returns:
the file extension, such as png or txt.

OOP Pop3Receiver Version 2.2

ALL CONTENTS COPYRIGHT 2005, OOP-Research Corporation. All rights reserved.
Any questions and comments are welcome to OOP-Research Corporation.