KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > core > util > MimeTypeConstants


1 /*
2  * Copyright (c) 2003 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenSubsystems
5  *
6  * $Id: MimeTypeConstants.java,v 1.6 2007/01/07 06:14:01 bastafidli Exp $
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21
22 package org.opensubsystems.core.util;
23
24 import java.util.HashMap JavaDoc;
25 import java.util.Map JavaDoc;
26
27 /**
28  * Known mime types.
29  * Originally copied from HandlerContext.java taken from Jetty 3.0.4
30  * now updated from mime.properties from Jetty 5.1.10.
31  *
32  * @version $Id: MimeTypeConstants.java,v 1.6 2007/01/07 06:14:01 bastafidli Exp $
33  * @author Julo Legeny
34  * @code.reviewer Miro Halas
35  * @code.reviewed 1.4 2005/07/29 07:36:24 bastafidli
36  */

37 public final class MimeTypeConstants
38 {
39    // Attributes ///////////////////////////////////////////////////////////////
40

41    /**
42     * Default Mime type
43     */

44    protected static String JavaDoc s_strDefaultMimeType = "text/html";
45
46    /**
47     * Hash map that will be stored types in
48     */

49    protected static Map JavaDoc s_mapMimeTypes = null;
50    
51    // Constructors /////////////////////////////////////////////////////////////
52

53    /**
54     * Static initializer;
55     */

56    static
57    {
58       s_mapMimeTypes = new HashMap JavaDoc(161);
59       s_mapMimeTypes.put("ai", "application/postscript");
60       s_mapMimeTypes.put("aif", "audio/x-aiff");
61       s_mapMimeTypes.put("aifc", "audio/x-aiff");
62       s_mapMimeTypes.put("aiff", "audio/x-aiff");
63       s_mapMimeTypes.put("asc", "text/plain");
64       s_mapMimeTypes.put("asf", "video/x.ms.asf");
65       s_mapMimeTypes.put("asx", "video/x.ms.asx");
66       s_mapMimeTypes.put("au", "audio/basic");
67       s_mapMimeTypes.put("avi", "video/x-msvideo");
68       s_mapMimeTypes.put("bcpio", "application/x-bcpio");
69       s_mapMimeTypes.put("bin", "application/octet-stream");
70       s_mapMimeTypes.put("cab", "application/x-cabinet");
71       s_mapMimeTypes.put("cdf", "application/x-netcdf");
72       s_mapMimeTypes.put("class", "application/java-vm");
73       s_mapMimeTypes.put("cpio", "application/x-cpio");
74       s_mapMimeTypes.put("cpt", "application/mac-compactpro");
75       s_mapMimeTypes.put("crt", "application/x-x509-ca-cert");
76       s_mapMimeTypes.put("csh", "application/x-csh");
77       s_mapMimeTypes.put("css", "text/css");
78       s_mapMimeTypes.put("csv", "text/comma-separated-values");
79       s_mapMimeTypes.put("dcr", "application/x-director");
80       s_mapMimeTypes.put("dir", "application/x-director");
81       s_mapMimeTypes.put("dll", "application/x-msdownload");
82       s_mapMimeTypes.put("dms", "application/octet-stream");
83       s_mapMimeTypes.put("doc", "application/msword");
84       s_mapMimeTypes.put("dtd", "application/xml-dtd");
85       s_mapMimeTypes.put("dvi", "application/x-dvi");
86       s_mapMimeTypes.put("dxr", "application/x-director");
87       s_mapMimeTypes.put("eps", "application/postscript");
88       s_mapMimeTypes.put("etx", "text/x-setext");
89       s_mapMimeTypes.put("exe", "application/octet-stream");
90       s_mapMimeTypes.put("ez", "application/andrew-inset");
91       s_mapMimeTypes.put("gif", "image/gif");
92       s_mapMimeTypes.put("gtar", "application/x-gtar");
93       s_mapMimeTypes.put("gz", "application/gzip");
94       s_mapMimeTypes.put("gzip", "application/gzip");
95       s_mapMimeTypes.put("hdf", "application/x-hdf");
96       s_mapMimeTypes.put("htc", "text/x-component");
97       s_mapMimeTypes.put("hqx", "application/mac-binhex40");
98       s_mapMimeTypes.put("html", "text/html");
99       s_mapMimeTypes.put("htm", "text/html");
100       s_mapMimeTypes.put("ice", "x-conference/x-cooltalk");
101       s_mapMimeTypes.put("ief", "image/ief");
102       s_mapMimeTypes.put("iges", "model/iges");
103       s_mapMimeTypes.put("igs", "model/iges");
104       s_mapMimeTypes.put("jar", "application/java-archive");
105       s_mapMimeTypes.put("java", "text/plain");
106       s_mapMimeTypes.put("jnlp", "application/x-java-jnlp-file");
107       s_mapMimeTypes.put("jpeg", "image/jpeg");
108       s_mapMimeTypes.put("jpe", "image/jpeg");
109       s_mapMimeTypes.put("jpg", "image/jpeg");
110       s_mapMimeTypes.put("js", "application/x-javascript");
111       s_mapMimeTypes.put("jsp", "text/plain");
112       s_mapMimeTypes.put("kar", "audio/midi");
113       s_mapMimeTypes.put("latex", "application/x-latex");
114       s_mapMimeTypes.put("lha", "application/octet-stream");
115       s_mapMimeTypes.put("lzh", "application/octet-stream");
116       s_mapMimeTypes.put("man", "application/x-troff-man");
117       s_mapMimeTypes.put("mathml", "application/mathml+xml");
118       s_mapMimeTypes.put("me", "application/x-troff-me");
119       s_mapMimeTypes.put("mesh", "model/mesh");
120       s_mapMimeTypes.put("mid", "audio/midi");
121       s_mapMimeTypes.put("midi", "audio/midi");
122       s_mapMimeTypes.put("mif", "application/vnd.mif");
123       s_mapMimeTypes.put("mol", "chemical/x-mdl-molfile");
124       s_mapMimeTypes.put("movie", "video/x-sgi-movie");
125       s_mapMimeTypes.put("mov", "video/quicktime");
126       s_mapMimeTypes.put("mp2", "audio/mpeg");
127       s_mapMimeTypes.put("mp3", "audio/mpeg");
128       s_mapMimeTypes.put("mpeg", "video/mpeg");
129       s_mapMimeTypes.put("mpe", "video/mpeg");
130       s_mapMimeTypes.put("mpga", "audio/mpeg");
131       s_mapMimeTypes.put("mpg", "video/mpeg");
132       s_mapMimeTypes.put("ms", "application/x-troff-ms");
133       s_mapMimeTypes.put("msh", "model/mesh");
134       s_mapMimeTypes.put("msi", "application/octet-stream");
135       s_mapMimeTypes.put("nc", "application/x-netcdf");
136       s_mapMimeTypes.put("oda", "application/oda");
137       s_mapMimeTypes.put("ogg", "application/ogg");
138       s_mapMimeTypes.put("pbm", "image/x-portable-bitmap");
139       s_mapMimeTypes.put("pdb", "chemical/x-pdb");
140       s_mapMimeTypes.put("pdf", "application/pdf");
141       s_mapMimeTypes.put("pgm", "image/x-portable-graymap");
142       s_mapMimeTypes.put("pgn", "application/x-chess-pgn");
143       s_mapMimeTypes.put("png", "image/png");
144       s_mapMimeTypes.put("pnm", "image/x-portable-anymap");
145       s_mapMimeTypes.put("ppm", "image/x-portable-pixmap");
146       s_mapMimeTypes.put("ppt", "application/vnd.ms-powerpoint");
147       s_mapMimeTypes.put("ps", "application/postscript");
148       s_mapMimeTypes.put("qt", "video/quicktime");
149       s_mapMimeTypes.put("ra", "audio/x-pn-realaudio");
150       s_mapMimeTypes.put("ra", "audio/x-realaudio");
151       s_mapMimeTypes.put("ram", "audio/x-pn-realaudio");
152       s_mapMimeTypes.put("ras", "image/x-cmu-raster");
153       s_mapMimeTypes.put("rdf", "application/rdf+xml");
154       s_mapMimeTypes.put("rgb", "image/x-rgb");
155       s_mapMimeTypes.put("rm", "audio/x-pn-realaudio");
156       s_mapMimeTypes.put("roff", "application/x-troff");
157       s_mapMimeTypes.put("rpm", "application/x-rpm");
158       s_mapMimeTypes.put("rpm", "audio/x-pn-realaudio");
159       s_mapMimeTypes.put("rtf", "application/rtf");
160       s_mapMimeTypes.put("rtx", "text/richtext");
161       s_mapMimeTypes.put("ser", "application/java-serialized-object");
162       s_mapMimeTypes.put("sgml", "text/sgml");
163       s_mapMimeTypes.put("sgm", "text/sgml");
164       s_mapMimeTypes.put("sh", "application/x-sh");
165       s_mapMimeTypes.put("shar", "application/x-shar");
166       s_mapMimeTypes.put("silo", "model/mesh");
167       s_mapMimeTypes.put("sit", "application/x-stuffit");
168       s_mapMimeTypes.put("skd", "application/x-koan");
169       s_mapMimeTypes.put("skm", "application/x-koan");
170       s_mapMimeTypes.put("skp", "application/x-koan");
171       s_mapMimeTypes.put("skt", "application/x-koan");
172       s_mapMimeTypes.put("smi", "application/smil");
173       s_mapMimeTypes.put("smil", "application/smil");
174       s_mapMimeTypes.put("snd", "audio/basic");
175       s_mapMimeTypes.put("spl", "application/x-futuresplash");
176       s_mapMimeTypes.put("src", "application/x-wais-source");
177       s_mapMimeTypes.put("sv4cpio", "application/x-sv4cpio");
178       s_mapMimeTypes.put("sv4crc", "application/x-sv4crc");
179       s_mapMimeTypes.put("svg", "image/svg+xml");
180       s_mapMimeTypes.put("swf", "application/x-shockwave-flash");
181       s_mapMimeTypes.put("t", "application/x-troff");
182       s_mapMimeTypes.put("tar", "application/x-tar");
183       s_mapMimeTypes.put("tar.gz", "application/x-gtar");
184       s_mapMimeTypes.put("tcl", "application/x-tcl");
185       s_mapMimeTypes.put("tex", "application/x-tex");
186       s_mapMimeTypes.put("texi", "application/x-texinfo");
187       s_mapMimeTypes.put("texinfo", "application/x-texinfo");
188       s_mapMimeTypes.put("tgz", "application/x-gtar");
189       s_mapMimeTypes.put("tiff", "image/tiff");
190       s_mapMimeTypes.put("tif", "image/tiff");
191       s_mapMimeTypes.put("tr", "application/x-troff");
192       s_mapMimeTypes.put("tsv", "text/tab-separated-values");
193       s_mapMimeTypes.put("txt", "text/plain");
194       s_mapMimeTypes.put("ustar", "application/x-ustar");
195       s_mapMimeTypes.put("vcd", "application/x-cdlink");
196       s_mapMimeTypes.put("vrml", "model/vrml");
197       s_mapMimeTypes.put("vxml", "application/voicexml+xml");
198       s_mapMimeTypes.put("wav", "audio/x-wav");
199       s_mapMimeTypes.put("wbmp", "image/vnd.wap.wbmp");
200       s_mapMimeTypes.put("wmlc", "application/vnd.wap.wmlc");
201       s_mapMimeTypes.put("wmlsc", "application/vnd.wap.wmlscriptc");
202       s_mapMimeTypes.put("wmls", "text/vnd.wap.wmlscript");
203       s_mapMimeTypes.put("wml", "text/vnd.wap.wml");
204       s_mapMimeTypes.put("wrl", "model/vrml");
205       s_mapMimeTypes.put("wtls-ca-certificate", "application/vnd.wap.wtls-ca-certificate");
206       s_mapMimeTypes.put("xbm", "image/x-xbitmap");
207       s_mapMimeTypes.put("xht", "application/xhtml+xml");
208       s_mapMimeTypes.put("xhtml", "application/xhtml+xml");
209       s_mapMimeTypes.put("xls", "application/vnd.ms-excel");
210       s_mapMimeTypes.put("xml", "application/xml");
211       s_mapMimeTypes.put("xpm", "image/x-xpixmap");
212       s_mapMimeTypes.put("xpm", "image/x-xpixmap");
213       s_mapMimeTypes.put("xsl", "application/xml");
214       s_mapMimeTypes.put("xslt", "application/xslt+xml");
215       s_mapMimeTypes.put("xul", "application/vnd.mozilla.xul+xml");
216       s_mapMimeTypes.put("xwd", "image/x-xwindowdump");
217       s_mapMimeTypes.put("xyz", "chemical/x-xyz");
218       s_mapMimeTypes.put("z", "application/compress");
219       s_mapMimeTypes.put("zip", "application/zip");
220    }
221    
222    // Constructors /////////////////////////////////////////////////////////////
223

224    /**
225     * Private constructor since this class cannot be instantiated
226     */

227    private MimeTypeConstants(
228    )
229    {
230       // Do nothing
231
}
232    
233    // Public methods ///////////////////////////////////////////////////////////
234

235    /**
236     * Method getting particular Mime type for the extension (key)
237     *
238     * @param strKey - key value for returning Mime type
239     * @return String
240     */

241    public static String JavaDoc getMimeType(
242       String JavaDoc strKey
243    )
244    {
245       String JavaDoc strMimeType = null;
246
247       // get value for particular key
248
strMimeType = s_mapMimeTypes.get(strKey).toString();
249       if ((strMimeType == null) || (strMimeType.trim().length() == 0))
250       {
251          strMimeType = s_strDefaultMimeType;
252       }
253       
254       return strMimeType;
255    }
256 }
257
Popular Tags