KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openuss > utility > MimeTypeChooser


1 /**
2  * Title: OpenUSS - Open Source University Support System
3  * Description: Utility for OpenUSS
4  * Copyright: Copyright (c) B. Lofi Dewanto
5  * Company: University of Muenster
6  * @author B. Lofi Dewanto
7  * @version 1.0
8  */

9 package org.openuss.utility;
10
11 import java.util.*;
12
13
14 /**
15  * Mime type chooser.
16  * This is used to choose the right content type for each
17  * file type.
18  *
19  * @author B. Lofi Dewanto
20  * @version 1.0
21  */

22 public class MimeTypeChooser {
23     // Resource
24
static ResourceBundle res = ResourceBundle.getBundle(
25                                         "org.openuss.utility.MimeTypeChooser");
26
27     // Constant
28
public static String JavaDoc NOT_AVAILABLE = "not_available";
29
30     /**
31      * Get the mime type.
32      */

33     public static String JavaDoc getMimeType(String JavaDoc extensionType) {
34         String JavaDoc result = "";
35
36         // Ignore capital/case
37
// Return null if you cannot find the mime type
38
try {
39             result = res.getString(extensionType.toLowerCase());
40         } catch (MissingResourceException ex) {
41             // Not Found, make a silent exception
42
// Not available mime type
43
result = getMimeType(MimeTypeChooser.NOT_AVAILABLE);
44         }
45
46         return result;
47     }
48 }
Popular Tags