1 /**
2 * Pyx4me framework
3 * Copyright (C) 2006-2008 pyx4j.com.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 *
18 * @author vlads
19 * @version $Id: ObexTypes.java 2872 2008-12-27 00:53:48Z vlads $
20 */
21 package com.pyx4me.maven.obex;
22
23 import java.util.Hashtable;
24
25 public class ObexTypes {
26
27 private static Hashtable types = new Hashtable();
28
29 static {
30 types.put("jpg", "image/jpeg");
31 types.put("jpeg", "image/jpeg");
32 types.put("gif", "image/gif");
33 types.put("png", "image/png");
34 types.put("mp3", "audio/mpeg");
35 types.put("txt", "text/plain");
36 types.put("jar", "application/java-archive");
37 types.put("jad", "text/vnd.sun.j2me.app-descriptor");
38 }
39
40 static String getFileExtension(String fileName) {
41 int extEnd = fileName.lastIndexOf('.');
42 if (extEnd == -1) {
43 return "";
44 } else {
45 return fileName.substring(extEnd + 1).toLowerCase();
46 }
47 }
48
49 static String getObexFileType(String fileName) {
50 return (String) types.get(getFileExtension(fileName));
51 }
52 }