View Javadoc

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