01: /**
02: * Title: OpenUSS - Open Source University Support System
03: * Description: Utility for OpenUSS
04: * Copyright: Copyright (c) B. Lofi Dewanto
05: * Company: University of Muenster
06: * @author B. Lofi Dewanto
07: * @version 1.0
08: */package org.openuss.utility;
09:
10: import java.util.*;
11:
12: /**
13: * Mime type chooser.
14: * This is used to choose the right content type for each
15: * file type.
16: *
17: * @author B. Lofi Dewanto
18: * @version 1.0
19: */
20: public class MimeTypeChooser {
21: // Resource
22: static ResourceBundle res = ResourceBundle
23: .getBundle("org.openuss.utility.MimeTypeChooser");
24:
25: // Constant
26: public static String NOT_AVAILABLE = "not_available";
27:
28: /**
29: * Get the mime type.
30: */
31: public static String getMimeType(String extensionType) {
32: String result = "";
33:
34: // Ignore capital/case
35: // Return null if you cannot find the mime type
36: try {
37: result = res.getString(extensionType.toLowerCase());
38: } catch (MissingResourceException ex) {
39: // Not Found, make a silent exception
40: // Not available mime type
41: result = getMimeType(MimeTypeChooser.NOT_AVAILABLE);
42: }
43:
44: return result;
45: }
46: }
|